import java.util.*;
public class NewVsOld {
public static void main(String[] args) {
// This is old style
// There is a better way to create the initial list:
// List oldList = Arrays.asList(args);
List oldList = new ArrayList();
for (int i=0;i<args.length;i++)
oldList.add(args[i]);
int cnt=0;
for (Iterator i = oldList.iterator(); i.hasNext(); ) {
String x = (String) i.next();
System.out.println(cnt + ": " + x);
cnt++;
}
// This is new style
// There is a better way to create the initial list:
// List oldList = new List();
List<String> newList = new ArrayList<String>();
for (int i=0;i<args.length;i++)
newList.add(args[i]);
cnt=0;
for (Iterator i = newList.iterator(); i.hasNext(); ) {
String x = (String) i.next();
System.out.println(cnt + ": " + x);
cnt++;
}
}
}