Insert an
array list of objects with addAll(ArrayList) method

In this section you will learn
to insert an array list of objects to another list. Here
is an example that provides the usage of the addAll(Arrayist) method in more detail.
Create a class "addAll" with an
ArrayList . Populate it with the object using the addAll(ArrayList) method.
Here is the Code of the Example :
AddAll.java:
import java.util.*;
public class addAll{
public static void main(String argv[]){
List v = new ArrayList();
v.addAll(Arrays.asList(new Integer[]{1,2,3,4}));
for(int i=0; i < v.size();i ++){
Integer iw =(Integer) v.get(i);
System.out.println(iw);
}
}
}
|
Here is the Output of the Example :
| C:\roseindia>javac VecAdd.java
C::\roseindia>java VecAdd
1
2
3
4 |

|