We have already used examples of multiple output statements such as:
System.out.println("The value of sum = " + sum);
When the length of an output statement exceeds one line of code, it can be broken up several different ways:
System.out.println("The sum of " + num1 + " and " + num2 +
" = " + (num1 + num2));
or
System.out.print("The sum of " + num1 + " and " + num2);
System.out.println( " = " + (num1 + num2));
You cannot break up a String constant and wrap it around a line.
System.out.print("A long string constant must be broken
up into two separate quotes. This will NOT work.");
System.out.print("A long string constant must be broken up"
+ " into two separate quotes. This will work.");
Last modified: December 12, 2022
Back to Reading Input With The...