Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
That's very easy task for all Java's users. I think, that it task is easely than other task's.
This comment is hidden because it contains spoiler information about the solution
Please use spoiler flag next time.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Thanks a lot!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
It works because a new object is returned. The variable 'x' does not change.
public String replace(char oldChar, char newChar)
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
Thanks for your guys' explanation!
Correct me if I'm wrong. So, if my understanding is correct, the reason "final" is used is to ensure that String x does not change in the hands of outsiders, and the reason "x.replace" works is because String x is an object...
Warning: a mutable object declared as final will still be mutable. The only thing that
final
locks is the binding between the variable name and the reference of the object in memory, so final "protects the code" only when used on immutable data structures or basic data types:Loading more items...