Crossfire JXClient, Trunk
Static Public Member Functions | Protected Member Functions | List of all members
ArrayIterator Class Reference
Collaboration diagram for ArrayIterator:
Collaboration graph

Static Public Member Functions

static< E > Iterator< E > iterator (final E[] array)
 
static void main (final String[] args)
 

Protected Member Functions

 ArrayIterator ()
 

Detailed Description

The code sample illustrates the usage of default methods in the JDK 8. Most implementations of Iterator don't provide a useful Iterator#remove() method, however, they still have to implement this method to throw an UnsupportedOperationException. With the default method, the same default behavior in interface Iterator itself can be provided.

Definition at line 43 of file ArrayIterator.java.

Constructor & Destructor Documentation

◆ ArrayIterator()

ArrayIterator.ArrayIterator ( )
protected

Close the constructor because ArrayIterator is part of the utility class.

Definition at line 48 of file ArrayIterator.java.

Member Function Documentation

◆ iterator()

static <E> Iterator<E> ArrayIterator.iterator ( final E[]  array)
static

Returns an iterator that goes over the elements in the array.

Parameters
<E>type of an array element
arraysource array to iterate over it
Returns
an iterator that goes over the elements in the array

Index of the current position

Returns the next element in the iteration

Returns
the next element in the iteration
Exceptions
NoSuchElementExceptionif the iteration has no more elements

Returns

true

if the iteration has more elements. (In other words, returns

true

if next returns an element, rather than throwing an exception.)

Returns
true
if the iteration has more elements

This method does not need to be overwritten in JDK 8.

Definition at line 59 of file ArrayIterator.java.

Referenced by main().

Here is the caller graph for this function:

◆ main()

static void ArrayIterator.main ( final String[]  args)
static

Sample usage of the ArrayIterator

Parameters
argscommand-line arguments

Definition at line 110 of file ArrayIterator.java.

References it, and iterator().

Here is the call graph for this function:

The documentation for this class was generated from the following file: