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
try{
System.out.println(" Arrays List string objects---");
ArrayList str1 = new ArrayList();
str1.add("Tom");str1.add("Pan");str1.add("Steve");
//calling static class directly with class name
Process.display(str1);
}catch(NumberFormatException e){
//
}
}
}// end of ClassTemplate1
//Reference super class
class Process{
Process() {} // constructor
public static void display(ArrayList str1 ){
for(String stx : str1)
{
System.out.println("\t"+ stx + " array of "+ str1.toString());
}
}
}
|