Page 1 of 1

Error in OCAJP Java 8 book

Posted: Mon Jul 20, 2020 3:44 am
by ardurn
Hello,

there is an error in section "12.1.3 Manipulating Strings" in the example code that a string manipulation method returns the same string if it is unchanged:

Code: Select all

System.out.println(s1.strip() == s1);
The strip method was introduced in Java 11 and therefore is not available in Java 8

Best regards
ardurn

Re: Error in OCAJP Java 8 book

Posted: Mon Jul 20, 2020 4:00 am
by admin
You are right. It should be trim()!
thank you for your feedback!