Generics, for-loop enhanced applications, static import, variable parameters, Aslist ()
1. Generic type
The data type is constrained, the format is < data type, such as:arraylist<int> alist=new arraylist<int> ();
Generic wildcard characters:<?> object and any class, <?extends e> E class and its subclasses, <?super E> class and its parent class.
2. For loop Enhanced application
1 arraylist<string> alist=new arraylist<string>(); 2 alist.add ("a"); 3 alist.add ("B"); 4 for (String str:alist) {5 System.out.println (str); 6 }78// output: A, b
3. Static Import
Format: Import static package name ... Class name. method name;.
Caveats: You can import directly to the level of a method, but the method must be static.
1 Import Static Java.lang.Math.abs; 2 3 Public class fin{4 Public Static void Main (string[] args) {5 SYSTEM.OUT.PRINTLN (ABS ( -1)); 6 }7 }
4. Variable parameters
Variable arguments (actually an array) can be used when the number of parameters is indeterminate.
Format: "Data type ..." variable name, such as: public static int Liverpool (int ... a)
Note: If a method has more than one parameter, the mutable parameter must be the last.
5, Aslist ();
1 string[] strarray={"A", "B", "C"}; 2 list<string> strlist=array.aslist (strarray); 3 for (String str:strlist) {4 System.out.pringln (str); 5 }67// output: A, B, C
Older dick Silk self-study note--java 0 basics to rookie--028