List reverse order java
Ngày đăng:
03/02/2022
Trả lời:
0
Lượt xem:
169
next prev Java Collections reverseOrder() MethodThe reverseOrder() is a Java Collections class method which returns a comparator that imposes the reverse of the natural ordering on the objects. There is two different types of Java reverseOrder() method which can be differentiated depending on its parameter. These are: Show
Java Collections reverseOrder() MethodThe reverseOrder() method of Java Collections class is used to get the comparator that imposes the reverse of the natural ordering on a collection of objects which implement the Comparable interface. Java Collections reverseOrder(comp) MethodThe reverseOrder() method of Java Collections class is used to get the comparator that imposes the reverse ordering of the specified comparator. SyntaxFollowing is the declaration of reverseOrder() method: Parameter
Returns
ExceptionsNA Compatibility VersionJava 1.5 and above Example 1Test it NowOutput: List sorted in ReverseOrder:
[90, 50, 10, -15, -20]
Example 2Test it NowOutput: List sorted in ReverseOrder:
[Ruby, Python, Java, COBOL]
Example 3Test it NowOutput: [Ruby, Commit, Pratham, Jaya]
Example 4Test it NowOutput: List sorted in ReverseOrder:
120
50
-20
-80
Next TopicJava Collections Class prev next |