[HD-OCP17/21-Fundamentals Pg 490, Sec. 17.1.6 - the-sort-method]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

[HD-OCP17/21-Fundamentals Pg 490, Sec. 17.1.6 - the-sort-method]

Post by raphaelzintec »

If you want to sort the list in the reverse order, you can change the lambda expression to, (a, b)->
-a.compareTo(b). Observe the minus sign in front of a.compareTo(b).

Or just b.compareTo(a)

dunno why you have not mentioned it

admin
Site Admin
Posts: 10398
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD-OCP17/21-Fundamentals Pg 490, Sec. 17.1.6 - the-sort-method]

Post by admin »

Yes, that is fine too.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 9 guests