Which of the following can fill in the blank so the following code prints true?
String v = " :) - (: ";
String really = v.trim();
String question = ;
System.out.println(really.equals(question));
length()
- 1)length()
)length()
- 1)length()
)C.
The trim()
method returns a String with all leading and trailing white space removed.
In this question, that's the seven-character String: ":) - (:".
Options A and B are incorrect because they do not remove the first blank space in v.
Option D is incorrect because it does not remove the last character in v.
Option C is correct.