Originally Posted by
javaDruide
In the case that vehicle.color is null what will happens? A null pointer error?
No, the string concatenation with + adds a
"null" string.
In other words the returned string is equivalent to:
"Chevy Uplander \nColor: null\n"
Note 1: using a bare \n is not a good thing. The newline sequence depends on the platform/operating system.
Note 2: you could also simply do:
String nl = "\n";
return "Chevy Uplander " + nl + "Color: " + vehicle.color + nl;
Note 3: in your code you are missing many ';'.