// Populate a List using Set elements. // Declare and Initialize the Collection Set<Integer> intSet = new HashSet<Integer>(); // Add Elements intSet.add(1); intSet.add(2); intSet.add(3); intSet.add(4); // Use the stream and collectors to Summarize all Integer elements System.out.println(intSet.stream().collect(Collectors.summarizingInt(p->((Integer)p)))); // Prints IntSummaryStatistics{count=4, sum=10, min=1, average=2.500000, max=4}