String str2 = " ";
str2.trim(); // if we use str2 = str2.trim(); the answer will be true true
System.out.println(str2.equals("") + " " + str2.isEmpty());
The trim() method in Java String is a built-in function that eliminates leading and trailing space
Answer is C
false false
Correct answer C because String is immutable so it can't be changed. Here trim() has no effect on str. If we had: "str = str.trim();" the correct answer would have been true true.
C is correct. You should try the following code.
public static void main(String[] args) {
String str = "";
str.trim ();
System.out.println (str.equals ("") + "" + str.isEmpty ());
}
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
letmein2
Highly Voted 5 years, 6 months agov323rs
Highly Voted 4 years, 11 months agoMPignaProTech
Most Recent 2 months agoKolodets
1 year, 7 months agoVicky_65
1 year, 8 months agoodzio33
1 year, 11 months agoRipfumelo
1 year, 11 months agoRoxyFoxy
2 years, 3 months agoXalaGyan
2 years, 10 months agoRaju15
3 years, 9 months agoAyla
4 years, 1 month agopillu2012
4 years, 3 months agohcampos
4 years, 3 months agotamanna786
4 years, 2 months agopillu2012
4 years, 3 months agohcampos
4 years, 3 months agoatlassi708
4 years, 1 month agoM_Jawad
4 years, 11 months ago