About Question enthuware.ocajp.i.v7.2.1054 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Smoljanov Sergej
Posts: 4
Joined: Mon Sep 15, 2014 8:24 am
Contact:

About Question enthuware.ocajp.i.v7.2.1054 :

Post by Smoljanov Sergej »

Note that line.concat("world") does not change line itself. It creates a new String object containing
"_hello_world__"
- _ - one space (forum replace 2 white space between world by 1 white space
but it is lost because there is no reference to it.
Similarly, calling trim() does not change the object itself.
So the answer is 8 + 5 = 13 !
more precise:
Note that line.concat("world") does not change line itself. It creates a new String object containing
"_hello__world"
- _ - one space (forum replace 2 white space between world by 1 white space
replace but it is lost because there is no reference to it.
Similarly, calling trim() does not change the object itself.

Code: Select all

      String blank = " ";// one space       
      String line = blank + "hello" + blank + blank;
      System.out.println("\""+line.concat("world")+"\"");

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

Re: About Question enthuware.ocajp.i.v7.2.1054 :

Post by admin »

You are right. Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests