package algus; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; public class VooValjund { public static void main(String[] args) { String[] m1=Stream.of("Juku", "Kati", "Mati").toArray(String[]::new); System.out.println(String.join(",", m1)); System.out.println(Stream.of("Juku", "Kati", "Mati"). collect(Collectors.joining("-")).toString()); //Tutvuge Collectors.partitioningBy(predicate) funktsiooniga //Lugege selle abil kokku, mitu eesnime on millise pikkusega //Avastus - partititioningBy vőimaldab jagada ainult kahte gruppi Map> nimed= Stream.of("Juku", "Kati", "Mati", "Anu", "Ain", "Madis"). collect(Collectors.groupingBy(s -> s.length())); System.out.println(nimed); for(Integer pikkus: nimed.keySet()){ System.out.println(pikkus+" - "+nimed.get(pikkus).size()); } Stream.of("Juku", "Kati", "Mati", "Anu", "Ain", "Madis"). collect(Collectors.groupingBy(s -> s.length())).entrySet().stream(). sorted((k1, k2) -> k2.getKey()-k1.getKey()). forEachOrdered(k -> System.out.println(k.getKey()+" "+k.getValue().size())); } }