Key Points 4.23
18. while (itr.hasNext())System.out.print(itr.next()+” “);
19. System.out.println(“Using ListIterator move reverse”);
20. while (itr.hasPrevious())
21. System.out.print(itr.previous()+” “);
22. }// end of main
23. }// end of vectorDemo
OUTPUT: Displaying Vector elements using vec.get()
10 20 30 40 50 60 70 Displaying
Vector elements using ListIterator
Using ListIterator move forward
10 20 30 40 50 60 70
Using ListIterator move reverse
70 60 50 40 30 20 10
Line No. 6: Vector<Integer> vec = new Vector<Integer>();creates
an object called vec of Vector<Integer>
Line No. 8: defines an array called x and assigns values to the array
Line Nos. 9 to 11: adds elements into Vector object.Integers are converted to objects auto-
matically by ...