A friend who has used C / C will not be unfamiliar with the word "generics"? I believe that friends with some Java encoding experiences or less encountered methods of using the collection class must be handmade. Look into the example below: Import java.util.ArrayList; import java.util.ITerator;
Public class myGenerics {
Public static void main (String [] args) {usenongenerics (); usegenerics ();} private static void useenongenerics () {arraylist alist = new arraylist (); alist.add (new integer (7)); alist.add ( New Integer (17)); int sum = 0; iterator it = alist.iterator (); while (ore.hasnext ()) {Sum = ((Integer) iter.next ()). INTVALUE ();} System SYSTEM .out.println (sum);} private static void usegenerics () {ArrayList
If there is time, I suggest you take the source code of the new java.util.collection to take a look, you can fully support our support generic API.