Home Tutorial Java Collections Arraylist Java new arraylist

 
 

Share on Google+Share on Google+
Java new arraylist
Posted on: October 23, 2009 at 12:00 AM
Advertisement
This section demonstrates the How to use of the new ArrayList in Java Programming.

  • Java ArrayList object is created with the reference of List interface
  • Object is also created directly by the ArrayList class


Java New Arraylist Example
import java.util.*;

public class List1 {

public static void main(String[] args) {
String  ar[]={"india","pakistan","United Kingdom","Japan"};
//ArrayList list=new ArrayList();
List list=new ArrayList();
list.add(ar[0]);
list.add(ar[1]);
list.add(ar[2]);
list.add(ar[3]);
System.out.println(list);
}
}
Output
[india, pakistan, United Kingdom, Japan]

Advertisement

Related Tags for Java new arraylist:


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.

Posted on: October 23, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com