This section demonstrates the How to use of the new ArrayList in Java Programming.
This section demonstrates the How to use of the new ArrayList in Java Programming.
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]