This program:
class Main {
public static void main (String args[]) {
String one = "no white space";
String two = " leading white space";
String three = "trailing white space ";
String four = " leading and trailing white space ";
System.out.println("\\"" + one.trim() + "\\"");
System.out.println("\\"" + two.trim() + "\\"");
System.out.println("\\"" + three.trim() + "\\"");
System.out.println("\\"" + four.trim() + "\\"");
}
}
yields this output:
"no white space"
"leading white space"
"trailing white space "
"leading and trailing white space "
Note that the trailing white space on the last two lines of output has not been trimmed.
fy-
I'll take this one. It's a trivial bug, and I'm looking at String.java anyway. . ..
class Main {
public static void main (String args[]) {
String one = "no white space";
String two = " leading white space";
String three = "trailing white space ";
String four = " leading and trailing white space ";
System.out.println("\\"" + one.trim() + "\\"");
System.out.println("\\"" + two.trim() + "\\"");
System.out.println("\\"" + three.trim() + "\\"");
System.out.println("\\"" + four.trim() + "\\"");
}
}
yields this output:
"no white space"
"leading white space"
"trailing white space "
"leading and trailing white space "
Note that the trailing white space on the last two lines of output has not been trimmed.
fy-
I'll take this one. It's a trivial bug, and I'm looking at String.java anyway. . ..