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

Answer by user_3380739 for Initialization of an ArrayList in one line

$
0
0

Here is code by abacus-common

// ArrayListList<String> list = N.asList("Buenos Aires", "Córdoba", "La Plata");// HashSetSet<String> set = N.asSet("Buenos Aires", "Córdoba", "La Plata");// HashMapMap<String, Integer> map = N.asMap("Buenos Aires", 1, "Córdoba", 2, "La Plata", 3);// Or for Immutable List/Set/MapImmutableList.of("Buenos Aires", "Córdoba", "La Plata");ImmutableSet.of("Buenos Aires", "Córdoba", "La Plata");ImmutableSet.of("Buenos Aires", 1, "Córdoba", 2, "La Plata", 3);// The most efficient way, which is similar with Arrays.asList(...) in JDK. // but returns a flexible-size list backed by the specified array.List<String> set = Array.asList("Buenos Aires", "Córdoba", "La Plata");

Declaration: I'm the developer of abacus-common.


Viewing all articles
Browse latest Browse all 37

Trending Articles



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