Is this statement:
String outString = null;
the same as this statement:
String outString = ""; // the string consisting of no characters
No. The first statement assigns the null value to a reference variable.
The second creates a
String object which contains no characters and assigns
its reference to the variable.
This is necessary because later in the program the
concatenation method is used to create a new object:
outString += caps ;
removes whitespace from both ends of its string.
White space consists of spaces and tabs.
" Both Sides Now ".trim()
"Both Sides Now"
Notice that interior whitespace is not removed.
trim() removes from both ends of the string all
characters that occur up to and including the space character in the unicode sequence of characters.
Since the space character has the code
this means that characters with a code less than that are
removed from both ends of the string.
This includes tabs and other non-printing characters.
Puzzle: What does the following evaluate to?