Computer Science
Write down the syntax of output statement in Java programming with an example
Java Intro
42 Likes
Answer
We commonly use two output statements in Java. There syntax are:
- System.out.println(<output value>); — This statement prints data on the console. The data to be printed is passed to the println method as a String. After printing the string, it places the cursor at the start of the next line. So the next printing happens at the start of the next line.
- System.out.print(<output value>); — This statement also prints data on the console. The data to be printed is passed to the print method as a String. After printing the string, the cursor remains on the same line at the end of the printed string. So the next printing starts in the same line just after the end of the previous printed string.
As an example, the below statements will generate the following output:
System.out.println("JVM stands for");
System.out.print("Java ");
System.out.print("Virtual ");
System.out.print("Machine");
Output
JVM stands for
Java Virtual Machine
Answered By
23 Likes