June 2018
Beginner
722 pages
18h 47m
English
Since Java 9, yet another option for creating and initializing a collection is available in each of the interfaces, including Map—the of() factory methods. They are called factory because they produce objects. There are eleven such methods, which accept from 0 to 10 parameters, each parameter being an element that has to be added to the collection, for example:
List<String> iList0 = List.of();List<String> iList1 = List.of("s1");List<String> iList2 = List.of("s1", "s2");List<String> iList3 = List.of("s1", "s2", "s3");Set<String> iSet1 = Set.of("s1", "s2", "s3", "s4");Set<String> iSet2 = Set.of("s1", "s2", "s3", "s4", "s5");Set<String> iSet3 = Set.of("s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10");Map<Integer ...
Read now
Unlock full access