Veit Ullmann

Greenhorn
+ Follow
since Sep 12, 2007
Veit likes ...
Eclipse IDE Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Veit Ullmann

I did check it very carefully and also checked the errata and that's the reason I posted it here.
The book's name is
OCP Oracle Certified Professional Java SE 11 Programmer 1
Study Guide Exam 1Z0-815
by Jeanne Boyarsky and Scott Selikoff.

Question: what is the output of the mentioned code.

A: [leo, Olivia]
B: [Olivia, leo]
and some other possible answers.

In the appendix on page 510 answer A is marked as correct, and I don't agree.

It should be answer B.


>> If you look at an ASCII table (one example here), you will find that Olivia does in fact come before leo.

That's what I wanted to say!

Maybe there is an error in Chapter 6 Review Question 11.
In my opinion correct answer should be B,
since the list is sorted in ascending order and would result in [Olivia, leo].  


List<String> cats = new ArrayList<>();
cats.add("leo");
cats.add("Olivia");

cats.sort((c1, c2) -> c1.compareTo(c2));

System.out.println(cats);

Output: [Olivia, leo]

which would be answer B, and not A.


cats.sort((c1, c2) -> c2.compareTo(c1)); would reverse the order or better: would sort in descending order.
In ${tomcat.source}\bin you have 2 folders i64 and x64 (if you have a 64 bit system). Just copy the correct tcnative-1.dll to ${tomcat.source}\bin.
12 years ago