Wednesday, 4 October 2023

JAVA

JAVA First program

Let Start Our first program

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

The main Method

The main() method is required and you will see it in every Java program:

public static void main(String[] args)

System.out.println()

Inside the main() method, we can use the println() method to print a line of text to the screen:

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. System is a built-in Java class that contains useful members, such as out, which is short for "output". The println() method, short for "print line", is used to print a value to the screen (or a file). Don't worry too much about System, out and println(). Just know that you need them together to print stuff to the screen. You should also note that each code statement must end with a semicolon (;).

No comments:

Post a Comment