Page 1 of 1
About Question enthuware.ocpjp.i.v11.2.1175 or v11.2.3577:
Posted: Wed Aug 26, 2020 2:59 pm
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?
Re: About Question enthuware.ocpjp.i.v11.2.1175 :
Posted: Wed Aug 26, 2020 11:50 pm
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.
Re: About Question enthuware.ocpjp.i.v11.2.1175 :
Posted: Thu Aug 27, 2020 2:25 am
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.
Re: About Question enthuware.ocpjp.i.v11.2.1175 :
Posted: Thu Aug 27, 2020 2:51 am
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.