Given this code fragment:
What is the output?
Java String objects are immutable, so trim() returns a new string rather than changing myStr. Because that returned value is not assigned, the original text remains unchanged, and its first space is at zero-based index 5.
String
trim()
myStr
Community Discussion