We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Strings
- Java Strings Introduction
- Discussions
Java Strings Introduction
Java Strings Introduction
Sort by
recency
|
1291 Discussions
|
Please Login in order to post a comment
Newbie Solution
import java.util.*;
public class Solution {
}
Strings in Java are immutable, so every invocation of
.substring(),.replace(),.toUpperCase()or concatenation with+creates a new String object. Thus, I prefer converting a String to character array or useStringBuilderclass that encapsulates a mutable buffer and provides a set of methods to operate on it in a meaningful name. In the end, it creates a new String, of course, but it scales well with the number of applied operations.My solution looks as follows:
import java.io.; import java.util.;
public class Solution {
}
mport java.io.; import java.util.;
public class Solution {
}