Share on Google+Share on Google+

Java arraylist of objects

This Java tutorial section, we demonstrates how to use objects in the Java ArrayList.

  • In arrayList object is added by default
  • This can be object of String, Integer or any Wrapper class

Example of Java Arraylist of Objects
import java.util.ArrayList;
import java.util.List;

public class List1 {
    public static void main(String[] args) {
       String name1=new String("mac");
       String name2=new String("jack");
       String name3=new String("john");
       String name4=new String("rob");

       List list=new ArrayList(4);
         for(int x=0;x





Posted on: October 23, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null