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

Answer by PRANAV SINGH for Initialization of an ArrayList in one line

$
0
0

Simplest way : you can use this approach to add multiple elements to any type of collection like ArrayList and HashSet

ArrayList<String> allViews = new ArrayList<String>();Collections.addAll(allViews,"hello","world","abc","def","ghi");

Viewing all articles
Browse latest Browse all 37

Trending Articles



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