Class OneCharIterator

  • All Implemented Interfaces:
    java.lang.Cloneable, java.util.Iterator

    public class OneCharIterator
    extends CharIterator
    Class providing an iterator for one character.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean bFirst  
      private char charCode  
    • Constructor Summary

      Constructors 
      Constructor Description
      OneCharIterator​(char c)
      Constructor
    • Field Detail

      • bFirst

        private boolean bFirst
      • charCode

        private char charCode
    • Constructor Detail

      • OneCharIterator

        public OneCharIterator​(char c)
        Constructor
        Parameters:
        c - the character that this iterator should iterate.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Description copied from class: CharIterator
        Specified by:
        hasNext in interface java.util.Iterator
        Specified by:
        hasNext in class CharIterator
        Returns:
        true if there is another element in the collection over which to iterate (since this iterator only handles one character, this will return false if it is past that character).
      • nextChar

        public char nextChar()
                      throws java.util.NoSuchElementException
        Specified by:
        nextChar in class CharIterator
        Returns:
        the next character, if there is one (since there is only one character over which to iterate, it must be the first character).
        Throws:
        java.util.NoSuchElementException - if past the first character