I am trying to write the code around this syntax.
public static void main(String[] args) {
Consumer<List<Integer>> methodRef = Collections::sort;
List<Integer> al = new ArrayList<>();
al.add(1);
al.add(4);
methodRef.accept(al);
System.out.println(methodRef);
}
the output is :
methodreferences.MethodReferenceTest$$Lambda$14/0x0000000800c01200@119d7047
please help me get the correct output.
I expect to see the list of sorted values method reference way.
>Solution :
Collections#sort sorts its input list.
System.out.println(al); to output the (now sorted) list.