The code
String c = "IceCream";
String upper = c.toUpperCase();
System.out.println(upper);
correctly prints “ICECREAM”. However, the original string c isn’t changed. Strings in Java are immutable so all operations on the string return a new copy.
More Related Contents:
- foo(int) is not applicable for the arguments (String)
- Replace a character specific number of times in String Java
- Java; Initializing A Count of Input, After Period Is Entered
- Difference between String replace() and replaceAll()
- Splitting a string at every n-th character
- How can I check if a single character appears in a string?
- Why is the String class declared final in Java?
- In Java, how do I check if a string contains a substring (ignoring case)? [duplicate]
- Fast algorithm for searching for substrings in a string
- Java change áéőűú to aeouu [duplicate]
- Extracting pairs of words using String.split()
- Extract Integer Part in String
- String replace a Backslash
- Why does this code using random strings print “hello world”?
- Remove all empty lines
- Does concatenating strings in Java always lead to new strings being created in memory?
- Java: String split(): I want it to include the empty strings at the end [duplicate]
- How can I safely encode a string in Java to use as a filename?
- When to use intern() on String literals
- How do I convert a String to a BigInteger?
- How to properly trim whitespaces from a string in Java?
- Garbage collection on intern’d strings, String Pool, and perm-space
- How Java do the string concatenation using “+”?
- Java compressing Strings
- Java String ReplaceAll method giving illegal repetition error?
- Unable to print russian characters
- Using DocumentFilter.FilterBypass
- Compare two hex strings in Java?
- Why does byteArray have a length of 22 instead of 20?
- Behavior of String literals is confusing