0
When declaring a list in java....
Is ArrayList<String> listA = new ArrayList<>(); And ArrayList<String> listA = new ArrayList<String>(); The same? One of them contains "String" on both side of the operator and the other only on one side.
3 Antworten
+ 5
Have you tried testing out the code yourself to see? Experimentation is one of the best part of programming in my opinion because it helps you learn and answer our own questions.
+ 5
Lenoname
In Latest Java version no need to write same thing on right side. You can left with only diamond operator.
+ 2
To respect the principle of SOLID, it is preferable to use the parent class or interface to initialize the variables:
List<String> named = New ArrayList<>()