Given the code fragment:
What is the result?
Java Strings are immutable, so calling trim() without reassigning its result has no effect on the original reference, which still holds a single space afterward. Comparing that string to "" with equals() checks character content, and a space is not the same as no characters, so it evaluates to false; isEmpty() checks only whether length() equals 0, and a string containing one space character also returns false for that check.
Community Discussion