What is the output?
String s = "ab"; s.toUpperCase(); System.out.println(s);
- AB
- Ab
- null
- ab
Strings are immutable: toUpperCase returns a new string, and the result is thrown away, so s is still "ab".
Play Problem Solving ▸
String s = "ab"; s.toUpperCase(); System.out.println(s);