253.
a.
b.
254.
What are some of the improvements made by Java 8 on
the List interface?
Answer:
Java 8 has added some methods to the List interface as follows:
List.sort: Java 8 has added the List.sort method. This
can be used to sort a List. It accepts as parameter a
Comparator and sorts the input
List as per the specified
Comparator.
List.replaceAll: Java 8 has added the
List.replaceAll method. This
can be used to replace all
the values in a List. It accepts as parameter a
UnaryOperator interface. UnaryOperator is a
specialization of the Function interface
that accepts an
input of a particular data type and returns a result of the
same data type. The replaceAll() method
applies the
UnaryOperator to each element in the List.
Do'stlaringiz bilan baham: