?? testlistallelements.java
字號:
import java.util.*;
public class TestListAllElements{
public static void main(String[] args) {
Vector h = new Vector();
h.add("1st");
h.add("2nd");
h.add("3rd");
h.add("4th");
h.add("5th");
printAll((Object)h);
printAll((Collection)h);
printAll((List)h);
printAll((Vector)h);
printAllGetByIndex( h );
}
public static void printAll(Object s){
System.out.println(s);
}
public static void printAll( Collection s ){
Iterator it = s.iterator();
while( it.hasNext() ){
System.out.println( it.next() );
}
}
public static void printAll( List s ){
ListIterator it = s.listIterator();
while( it.hasNext() ){
System.out.println( it.next() );
}
while( it.hasPrevious() ){
System.out.println( it.previous() );
}
}
public static void printAll( Vector s ){
Enumeration em = s.elements();
while(em.hasMoreElements()) {
System.out.println(em.nextElement());
}
}
public static void printAllGetByIndex( List s ){
int size = s.size();
for( int i=0; i<size; i++ ){
System.out.println(s.get(i));
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -