Collection集合的常用功能
import java. util. ArrayList;
import java. util. Collection;
public class demoCollection {
public static void main ( String[ ] args) {
Collection c = new ArrayList ( ) ;
System. out. println ( c) ;
System. out. println ( "==================" ) ;
boolean c1 = c. add ( "迪迦奥特曼" ) ;
boolean c2 = c. add ( "戴拿奥特曼" ) ;
System. out. println ( c) ;
System. out. println ( "==================" ) ;
boolean c3 = c. remove ( "戴拿奥特曼" ) ;
boolean c4 = c. remove ( "杰克奥特曼" ) ;
System. out. println ( "c3 = " + c3 + "; c4 = " + c4) ;
System. out. println ( c) ;
System. out. println ( "==================" ) ;
boolean c5 = c. contains ( "迪迦奥特曼" ) ;
boolean c6 = c. contains ( "杰克奥特曼" ) ;
System. out. println ( "c5 = " + c5 + "; c6 = " + c6) ;
System. out. println ( "==================" ) ;
boolean is = c. isEmpty ( ) ;
System. out. println ( is) ;
System. out. println ( "==================" ) ;
int s = c. size ( ) ;
System. out. println ( s) ;
System. out. println ( "==================" ) ;
Object[ ] arr = c. toArray ( ) ;
for ( int i = 0 ; i < arr. length ; i++ ) {
System. out. println ( arr[ i] ) ;
}
System. out. println ( "==================" ) ;
System. out. println ( c) ;
c. clear ( ) ;
System. out. println ( c) ;
}
}