Current location - Quotes Website - Signature design - Java Help Questions about Generic
Java Help Questions about Generic

Personal opinion:

If you want to write a basic data type for List's generic type, you generally need to use its wrapper class: List ..., because int is not a reference type , while Integer is a reference type.

In Java, arrays are treated as objects (reference types). Therefore, when you new an int[], such as arr1, then arr1 is an object (reference type), so it can be written in angle brackets.

Then you can write a for loop (or for-each loop) and use the get() method to get the elements in the List. You can find that each time you take out an array of int or char .

The Arrays.asList() method returns a List object, that is, the array of String s[] returns a List object through the Arrays.asList(s) method. Therefore List and List are definitely not equal.

How to add non-basic type arrays to references in List:

List list3 = new ArrayList(); ?

list3.add(arr3);