In order to store data in a Collection class and set it to the same type. We use the generic mechanism introduced by JDK1.5. The type in angle brackets is the type of input parameters and return values. For example, ArrayList <String> data = new ArrayList <String> (); both input parameters and output return values are of the String type by default. Therefore, forced type conversion is no longer required in the program. You can use the Foreach method to conveniently access methods in a set. It is equivalent to calling the Iterator method to output information. [Java] for (Stringa: list) {<span style = "white-space: pre"> </span> System. out. println (a);} is equivalent to: [java] Iterator I = list. iterator (); while (I. hasNext () {<span style = "white-space: pre"> </span> System. out. print (I. next () + "");} routine: [java] List <String> list = new ArrayList <String> (); list. add ("Welcome"); list. add ("to"); list. add ("China! "); For (String a: list) {<span style =" white-space: pre "> </span> System. out. print (a + "");} Iterator I = list. iterator (); while (I. hasNext () {<span style = "white-space: pre"> </span> System. out. print (I. next () + "");