import java.util.*;
public class List1 {
public static void main(String[] args) {
ArrayList list = new ArrayList();
Iterator it;
int i;
for(i = 0; i < 5; i++)
list.add(new Integer(i));
for(i = 0; i < list.size(); i++)
System.out.println(list.get(i));
list.set(3, new Integer(33));
list.set(4, new Integer(44));
Integer[] ai = (Integer[])list.toArray(new Integer[1]);
for(i = 0; i < ai.length; i++)
System.out.println(ai[i]);
System.out.println("has 1? : " + list.contains(new Integer(1)));
list.clear();
System.out.println("isEmpty(): " + list.isEmpty());
}
}
List1.java output
0
1
2
3
4
0
1
2
33
44
has 1? : true
isEmpty(): true
Tag: Study Code Program Java
No comments:
Post a Comment