There is no difference. Starting from jdk1.7, you can omit the String in the angle brackets on the right. (The right-hand side is inferred by the generic within the declaration, so no need.)
List<Sting> list =new ArrayList<>();
List<Sting> list =new ArrayList<String>();
There is no difference between the two. The above ArrayList will also be automatically converted to the generic type of String. The data type that the list can access can only be the String type. And if your first line of code is changed to
List list = new ArrayList();
This makes a big difference. The data type accessed by list is not fixed. You can access String, Integer or even Object types.
The first one must be written after jdk1.7, otherwise there will be a compilation error. The latter one must be written before 1.7. Of course, it can also be written like this after 1.7
No difference. . The data type is specified when List<String>.
JDK 1.7 features added support for type inference.
There is no difference. Starting from jdk1.7, you can omit the String in the angle brackets on the right.
(The right-hand side is inferred by the generic within the declaration, so no need.)
If you express it
There is no difference between the two. The above ArrayList will also be automatically converted to the generic type of String. The data type that the list can access can only be the String type. And if your first line of code is changed to
This makes a big difference. The data type accessed by list is not fixed. You can access String, Integer or even Object types.
The first one must be written after jdk1.7, otherwise there will be a compilation error. The latter one must be written before 1.7. Of course, it can also be written like this after 1.7
After jdk1.7, there is no difference