About Question enthuware.ocpjp.i.v11.2.1175 or v11.2.3577:

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

Moderator: admin

Post Reply
Michalrk1978
Posts: 9
Joined: Thu May 07, 2020 5:15 pm
Contact:

About Question enthuware.ocpjp.i.v11.2.1175 or v11.2.3577:

Post by Michalrk1978 »

"replace(char oldChar, char newChar) method returns the same String object if both the parameters are same, i.e. if there is no change." - Is the behavior of this method documented in any official Oracle documentation? Could you please provide a source from which to find out such details of how the standard Java API works?

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

Re: About Question enthuware.ocpjp.i.v11.2.1175 :

Post by admin »

You can get such details from JavaDoc API documentation. For example, JavaDoc API documentation for replace method says:
If the character oldChar does not occur in the character sequence represented by this String object, then a reference to this String object is returned.

Michalrk1978
Posts: 9
Joined: Thu May 07, 2020 5:15 pm
Contact:

Re: About Question enthuware.ocpjp.i.v11.2.1175 :

Post by Michalrk1978 »

I have read the JavaDoc API documentation for the replace method and in my opinion it does not explain this method's behavior
"String".replace('g','g')=="String" - the character 'g' occur in the character sequence "String", so the quoted piece of documentation doesn't explain the behavior of the method.

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

Re: About Question enthuware.ocpjp.i.v11.2.1175 :

Post by admin »

Sorry, my mistake. You are right. That statement doesn't explain the behavior. Let me see if I can find a valid reference.
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests