We have already used examples of multiple output statements such as:
System.out.println("The value of sum = " + sum);
There will be occasions when the length of an output statement exceeds one line of code. This 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. This is not valid:
String
System.out.print("A long string constant must be broken up into two separate quotes. This will NOT work.");
However, this will work:
System.out.print("A long string constant must be broken up" + "into two separate quotes. This will work.");