New Array in Java:
String[] s;//is defined without the need to set the size S = new string[5];//to set the size of the array when allocating space for arraylist,arraylist<string> result = new arraylist& Lt String> ();//This time you do not need to set the size, Result.add (string) to add an element, Result.remove (string) Delete an element, the size can be obtained by result.size () Again see Java allow map[] Maparray = new map[5]; also allow map<integer,string>[] Maparray = new map[5]; Map<integer,string not allowed >[] Maparray = new map<integer,string>[5];//does not allow new to be an array with a generic typein the case of Java SE 1.5, without generics, by referencing the type object to implement the "arbitrariness" of the arguments, the disadvantage of "arbitrariness" is to make explicit coercion of type conversions, and this conversion is required by the developer for the actual parametersThe type can be predicted in the case of the. The benefit of generics is that it checks for type safety at compile time, and all casts are automatic and implicit, increasing the rate of reuse of the code. Generics are the types that are displayed to tell the compiler container, such as map<integer,string> is a generic type.
(reprint) New arrays in Java and ArrayList Java does not allow generic arrays