Quantcast
Channel: Initialization of an ArrayList in one line - Stack Overflow
Viewing all articles
Browse latest Browse all 37

Answer by Amar kumar Nayak for Initialization of an ArrayList in one line

$
0
0

You can use of() method from java 9 onwards

List<String> places = List.of("Buenos Aires","Córdoba","La Plata");

of() methods create immutable list.If you want to modifie you got exception.


Viewing all articles
Browse latest Browse all 37


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>