In this example we are converting values of an array into collection.
List interface is a member of the Java Collection
Framework and extends Collection interface. List
interface is an ordered collection which follows insertion order, typically allow duplicate
elements. The List interface provides a special iterator, called ListIterator
for insertion, replacement and bi-directional access.
The Arrays class contains various methods for manipulating arrays (e.g. sorting and searching etc.) and extends the Object class. The Iterator class allows access to the elements of a collection.
hasNext(): This method is used to get more elements. If the element at the next position is found then returns true otherwise throws an exception.
next(): This method returns the next element in the iteration.
asList(Object a): This method acts as a bridge between array and collection. This method converts array into Arrays by internally using Colletion.toArray() method .
The code of the program is given below:
The output of the program is given below:
The values into Array Java Struts JSP J2EE
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: December 19, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles