Given the following code fragment:
What is the output?
trim() does not change the value because there is no leading or trailing whitespace. In "Sweet Sweat", charAt(6) returns S, and indexOf("Sw", 1) returns 6 because "Sw" begins at index 6. Concatenation produces S 6.
trim()
"Sweet Sweat"
charAt(6)
S
indexOf("Sw", 1)
"Sw"
S 6
Community Discussion