+91 81900 98289

Java Output

System.out.println prints the value and then starts a new line. System.out.print stays on the same line. Use println for normal lessons so each result is easy to see.

printf borrows its format from C. %s is text, %d is an integer, and %n is a new line. Prefer println until the layout of a report actually needs columns.

Example

print writes Batch and a space. println then writes 12 and moves down. printf fills %s with Chennai.

public class Output { public static void main(String[] args) { System.out.print("Batch "); System.out.println(12); System.out.printf("City: %s%n", "Chennai"); } }
System.out is the standard output stream. Error messages that should stay separate from normal results go to System.err.