About Question enthuware.ocpjp.v17.2.3321 :

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

Moderator: admin

Post Reply
TarunP
Posts: 1
Joined: Sat Nov 19, 2022 8:14 am
Contact:

About Question enthuware.ocpjp.v17.2.3321 :

Post by TarunP »

books.sort(Comparator.comparing(Book::getGenre).thenComparing(Book::getTitle).reversed());

This reverses both the values (Genre and Title).
How do I reverse only the Title? Thanks

//result
[{non-fiction':Uri'}, {non-fiction':Becoming'}, {fiction':The Outsider'}, {fiction':Cujo'}]

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

Re: About Question enthuware.ocpjp.v17.2.3321 :

Post by admin »

Instead of calling reversed() at the end, pass the reverse compartor in thenComparing.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest