nside the main() method, you can use the println() method to print a line of text to the screen. Here's a quick recap:

  1. System.out.println(): In Java, System.out is an object that represents the standard output stream. It provides methods for printing data to the console. The println() method is one such method, which is used to print a line of text to the console.

  2. Usage: You can use the println() method to display messages, variables, or any other information to the user. It automatically adds a newline character at the end of the output, so each call to println() starts a new line.


public static void main(String[] args) {
  System.out.println("Hello World");
}
 

Note: The curly braces {} marks the beginning and the end of a block of code.

Note: Each code statement must end with a semicolon.



Practice Excercise Practice now