Q&A

Q1:How can I set the value of a string variable to be blank?
A1: A pair of double quotation marks without any text between them is considered to be an empty string. You can set a string variable equal to this upon its creation or in other parts of your programs. The following code creates a new string variable called adaSays and sets it to nothing:
String adaSays = "";
Q2:Is there a way to make the text in one println() statement start right at the end of the text in the preceding println() statement? I don't want the second println() statement to start at the beginning of a new line, but it always does.
A2: Java automatically ends each System.out.println() statement with its own new line, so the only way to prevent this is to use a statement ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.