In this article, we are going to understand the working of the "Hello World" program in Java.
Java Program:
// Java First Program class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Hello, World!
In the above code, the first line of code defined a new class called HelloWorld because in Java all code must be contained within classes, so this is the starting point of our program.
The next line public static void main(String[] args) defines a main method within the HelloWorld class. The main method is the entry point for the program and is the first method that is called when the program is run. It takes an array of String objects called args as a parameter.
The next line System.out.println("Hello, world!"); to print the message "Hello, world!" to the console. The println method adds a new line character after the message, so the next line of output will start on a new line.
No comments:
Post a Comment