ArraysToArrayListGenerics1
 

Complete Code :

//Collection_ArrayList1.htm
import java.io.*;
import java.lang.reflect.*;
import java.util.*;

public class ClassTemplate1 {

public String str1; private String str2; public ClassTemplate1() {
// TODO Auto-generated constructor stub
str2="encapsulated strictly Private scope";
System.out.println(str2);
}

public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
String[] array1 = {"Jan" ,"Feb", "Mar"};
try{
System.out.println(" Arrays List string objects---");
ArrayList<String> str1 = new ArrayList<String>();
str1.add("Tom");str1.add("Pan");str1.add("Steve");
//calling static class directly with class name
Process.display1(str1);
//filling ArrayList with array
ArrayList<String>alist = new ArrayList<String>();
for(int i =0; i < array1.length; i++)
{
alist.add(array1[i]);
}
Process.display1(alist);//

}catch(NumberFormatException e){
//
}
}
}
//Reference super class
class Process{
Process() {} // constructor

public static void display1(ArrayList<String> str1 ){
for(String stx : str1)
{
System.out.println("\t"+ stx + " array of "+ str1.toString());
}
}

}

Runtime Views: