Re: Question on .iterator()

Iterator is an Interface. And as far as I know, there can't be objects of type interface.

So this method returns an object, that can be referenced by the Iterator interface. But what is the exact type of the object ?

Is it an ArrayList ?

The class you got that Iterator from returns an object of a class that implements the Iterator interface; the class you got that Iterator from implements the Iterable interface (preferably). That actual class that implements the Iterator interface is none of our business, as long as it does what it has to do (and no, it isn't an ArrayList).

kind regards,

Jos

The only person who got everything done by Friday was Robinson Crusoe.

Re: Question on .iterator()

Just so you know what this means (as it can be helpful, albeit rarely):
class java.util.AbstractList$Itr

If you look at the source code for AbstractList you will see, defined inside it, a concrete class that implements the Iterator interface, called Itr.
So the $ symbol means "inner class", followed by the name of the inner class.
If you saw "class java.util.AbstractList$1" that is the first anonymous inner class.

Because, as Jos says, it's not something people are supposed to use directly.
Indeed, since it's private, they can't.
So, in the same way private methods do not appear in an API, private classes don't either.