# Iterator Java SequenceIterator Methods

> The iterator Java SequenceIterator methods are used to extract and iterate the object's sequence elements, determine the sequence element type, size and position within the iterator's sequence, determine the sequence tile size, and, for RLE encoded sequences, determine the repeat count or decode the RLE sequence to a non-RLE sequence.

> The iterator operation can be one of the following:

> `public int get(Object buffer)` | Extract the sequence elements into the provided array `buffer` . This array should have the same element type as sequence element type. Return the actual number of elements extracted (which can be smaller than the array size in case of reaching the end of the array)
> `public Object next()` | Get the next element of the sequence. Return the object wrapper for the next sequence element or `null` if the end of the sequence is reached
> `public int nextInt()` | Get the next integer element of the sequence . Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public long nextLong()` | Get the next long integer element of the sequence. Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public float nextFloat()` | Get the next float element of the sequence . Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public double nextDouble()` | Get the next double element of the sequence . Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public byte[] nextBytes()` | Get the next char element of the sequence . Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public String nextString()` | Get the next string element of the sequence . Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public Date nextDate()` | Get the next date element of the sequence . Return the next sequence element value ( throws a `NoSuchElementException` if the iterator has no more elements)
> `public long firstPosition()` | Get the position of the first sequence element. Return the position of the element at which this sequence starts (inclusive)
> `public long lastPosition()` | Get the position of the last sequence element. Return the position of the element at which this sequence ends (inclusive)
> `public long nextPosition()` | Return the position of element returned by subsequent invocation of the `next()` or `nextTile()` method
> `public boolean nextTile()` | Advance the iterator to the next tile. Return `true` if the iterator has successfully advanced, `false` otherwise
> `public int elemSize()` | Return the sequence element size
> `public Object tileItems()` | Get the items of the current tile. Return an array with tile items
> `public Sequence.Type type()` | Return the type of the underlying sequence
> `static native public boolean isRLE()` | Check if the underlying sequence implementation uses RLE format (in this case a repeat counter is associated with each sequence element)
> `public int itemRepeatCount(int i)` | Get the RLE count for the tile item ( For non-RLE implementation of sequences this method always returns 1)
> `public SequenceIterator rleDecode()` | Decode the RLE sequence to a non-RLE sequence (For non-RLE implementation this method just copies the sequence iterator)
> `public void reset()` | Reset (rewind) the sequence position to the first element
> `public void close()` | Close and release the sequence internal resources

> ## Example

> Following is an example code snippet demonstrating sequence iteration using the `next()`method:

>         private static int printFloatSequence(Quote quote, SequenceIterator iterator)
>         {
>             System.out.print(quote.symbol + ": {");
>             Object elem;
>             int i;
>             for (i = 0; (elem = iterator.next()) != null; i++)
>             {
>                 if (i != 0)
>                     System.out.print(",");
>                 System.out.format("%.3f", elem);
>             }
>             System.out.println("}");
>             return i;
>         }