I am studying java Stream and having hard time solving questions below. The reason why I got stuck is because I have no idea about dealing with Stream<Integer>
.
I stumbled upon a solution of "count" by doing list.stream().count()
, but other than this, I can't proceed further. Please help me how to deal with these problems and tell me why list.stream().count()
works in this situation. So far, I've tried everything I've learned.
public class Question {
public static void main(String[] args) {
List<Integer>list = Arrays.asList(5,3,4,1,2);
System.out.println("sum by using Stream : " + sum);
System.out.println("count by using Stream: " + count);
System.out.println("average by using Stream : " + avg);
System.out.println("sort by using Stream");
}
}