Collection set of commonly used functions

demo06 Package; 

Import of java.util.ArrayList;
Import java.util.Collection;

/ *
* Classes in java.util
interfaces Collection <E>
*
* top level interface for all single set, which defines a common set of methods for all single
* arbitrary the method can use a separate set of interface collection
* common method
* boolean add (E e)
Ensures that this collection contains the specified element (optional operation).
*
*
*
Void Clear ()
Removes all elements (optional operation) from this collection.
* * /
Public class demo06 {
public static void main (String [] args) {
// create a collection object polymorphic
Collection <String> = new new Coll the ArrayList <> ();
System.out.println (Coll); / / print empty rewrite toString method

/ *
* Public boolean add (E e) the given object to the current collection;
* return value is a boolean value, generally returns true, so you can not received;
* * /
boolean B1 = coll.add ( "John Doe ");
System.out.println (" B1 "+ B1); b1true //
System.out.println (Coll);

// public Boolean remove (E E); deleted exists returns to true
Boolean coll.remove B2 = ( "Joe Smith");
System.out.println (Coll);

}
}

Guess you like

Origin www.cnblogs.com/Damocless/p/11875854.html