Iterator Problems

If you havent noticed Javas Vector Class by default doesnt have a method for returning an iterator. It does however inherit off AbstractList, which in essence has a listIterator method, but i dont think the Vector class actually provided implementation to return a listIterator of all the objects inside the list. Generally iterators in Java are used on for example LinkedLists which is farily popular to use iterators on, and LinkedList has a method which returns it called the listIterator() method.

To traverse a Vector list just simply do it as if you were doing it with a ArrayList, Vector in Java is essentially the same as an ArrayList i think except its synchronized.
 
What I was really trying to get at was that the above code (using an iterator with a vector) works fine if you were programming with the Java JDK1.4.2. However in J# some methods (which are available in Java) are not in J#. For example there is also a get method in the JDK version of Vector with in non-existent in J#, which makes it very hard to migrate.
 
haroldjclements said:
What I was really trying to get at was that the above code (using an iterator with a vector) works fine if you were programming with the Java JDK1.4.2. However in J# some methods (which are available in Java) are not in J#. For example there is also a get method in the JDK version of Vector with in non-existent in J#, which makes it very hard to migrate.


Yeah i know what you mean... but the reason why they dont have some of the methods, or probably they do is compatibility reasons with the framework, because in other languages like C# its rather similar to Java, and to make it cross compatible, they standardise some of the method naming i think... so in J# instead of the get method we have the elementAt method.
 
Back
Top