public interface IteratorNumber
IteratorByte
, IteratorShort
,
IteratorInt
, IteratorLong
, IteratorFloat
and
IteratorDouble
.
We looked into making this class implement Iterator, but unfortunately,
because of generics being invariant, we cannot provide a scheme that would work naturally
in all cases. Ideally, we would want to have IteratorNumber
be Iterator<Number>
and IteratorDouble
be Iterator<Double>
, but this does
not work because generics are invariant. We could have
Iterator<T extends Number>
and Iterator<Double>
, but that would
mean IteratorNumber
would need a type parameter, and the user of the
API would have to use bound type parameters like IteratorNumber<? extends Number>
,
which is awful. We could have all extend Iterator<Number>
but then
the foreach loops would return Number
in all cases, even for collections
of more specific type.
Modifier and Type  Method and Description 

boolean 
hasNext()
Returns
true if the iteration has more elements. 
byte 
nextByte()
Returns the next element in the iteration casted to a byte.

double 
nextDouble()
Returns the next element in the iteration casted to a double.

float 
nextFloat()
Returns the next element in the iteration casted to a float.

int 
nextInt()
Returns the next element in the iteration casted to an int.

long 
nextLong()
Returns the next element in the iteration casted to a long.

short 
nextShort()
Returns the next element in the iteration casted to a short.

boolean hasNext()
true
if the iteration has more elements.
(In other words, returns true
if nextXxx
would
return an element rather than throwing an exception.)true
if the iteration has more elementsfloat nextFloat()
NoSuchElementException
 if the iteration has no more elementsdouble nextDouble()
NoSuchElementException
 if the iteration has no more elementsbyte nextByte()
NoSuchElementException
 if the iteration has no more elementsshort nextShort()
NoSuchElementException
 if the iteration has no more elementsint nextInt()
NoSuchElementException
 if the iteration has no more elementslong nextLong()
NoSuchElementException
 if the iteration has no more elementsCopyright © 2015. All rights reserved.