Given:
What is the result?
Given:
What is the result?
The method trim() in Java removes leading and trailing whitespace from the string but does not affect spaces between words. The given string 'Java SE 8 1' contains no leading or trailing whitespace, so the trim() method does not modify it. The length of the string 'Java SE 8 1' is 11 characters including spaces. Therefore, the correct answer is 11.
D is correct because trim() only removes leading and lagging spaces.
No trim() just remove space on first and last string
Answer is B. String s = "Java SE 8 1"; int len = s.trim().length(); System.out.print(len);
Answer is B trim() removes only begining and end white spaces of a string
See the code: public static void main (String[] args) { String s = "Java SE 8 1"; int len = s.trim().length(); System.out.print(len); }
Correct.
Answer is B - 11. Just calculate spaces before and after string.
Answer is B.
Answer is: 11
D is correct, because trim remove only spaces and remember, can't be 8 because is true that Java indexes form 0, but not in case of count de size of String. I tested
Tested D. 9
String s = "Java Duke"; int len = s.trim().length(); System.out.println(len); D