| Author |
In which class the Interface Iterator is implemented for Vector class
|
Arun raghvan
Ranch Hand
Joined: Aug 22, 2010
Posts: 75
|
|
In which class the Interface Iterator is implemented for Vector class
the code is shown below: where i don't implement the interface Iterator where it is defined.
|
 |
Wouter Oet
Saloon Keeper
Joined: Oct 25, 2008
Posts: 2700
|
|
|
I really don't understand your question. The Vector class implements the Iterable interface. Is that what you mean?
|
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
|
 |
Arun raghvan
Ranch Hand
Joined: Aug 22, 2010
Posts: 75
|
|
Wouter Oet wrote: The Vector class implements the Iterable interface. Is that what you mean?
Yes ,Vector class must have implemented Iterator interface ...right ,why should it must implement Iterable...I can't understand the hierarchy is bit confusing. And On the following code i used iterator() Method where it is defined
sorry,my question was bit confusing.
|
 |
Wouter Oet
Saloon Keeper
Joined: Oct 25, 2008
Posts: 2700
|
|
|
The iterator method is defined in the Iterable interface and the vector implements that interface. If you're confused with the hierarchy just look at the java.util.Vector
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Many Collection classes have a private inner class that implements Iterator. An instance of this class is returned. But you don't need to know what the actual class is. All you need to know is that it implements Iterator, and therefore has working hasNext() and next() methods, and possibly also a working remove() method (I said possibly since it's allowed to throw a UnsupportedOperationException from it).
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: In which class the Interface Iterator is implemented for Vector class
|
|
|