I have a string:
String c = "IceCream";
If I use toUpperCase()
function then it returns the same string, but I want to get "ICECREAM"
.
Where is the problem?
See Question&Answers more detail:osI have a string:
String c = "IceCream";
If I use toUpperCase()
function then it returns the same string, but I want to get "ICECREAM"
.
Where is the problem?
See Question&Answers more detail:osThe 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.