recently learned about the collection framework, doing book examples. The
code is as follows:
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add("");
list.add("");
list.add("");
System.out.println(list.contains(""));
list.remove(0);
System.out.println("----------------------------");
list.set(1,"");
for(int i=0; i<list.size(); iPP) {
String name = (String)list.get(i);
System.out.println(name);
}
System.out.println("-----------------------------");
System.out.println(list.indexOf(""));
list.clear();
System.out.println("-----------------------------");
for(Object obj:list) {
String name = (String)obj;
System.out.println(name);
}
System.out.println(list.isEmpty());
}
}
Code compilation result:
---------------------------------------------
:
:
:
*Arrays
----------------------2-----------------------
printenv:
----------------------3-----------------------
unset CLASSPATH: