Posts

Showing posts with the label how to print Hello World in Java

How to print Hello World! in JAVA language

How to print Hello World! : Let's start by creating a simple program that prints “Hello World” to the screen. class MyClass {     public static void main(String[ ] args) {         System.out.println("Hello World");     } } In Java, every line of code that can actually run needs to be inside a class. In our example, we named the class MyClass. You will learn more about classes in the upcoming modules. In Java, each application has an entry point, or a starting point, which is a method called main. Along with main, the keywords public and static will also be explained later. The main Method To run our program, the main method must be identical to this signature: public static void main(String[ ] args) -> public: anyone can access it -> static: method can be run without creating an instance of the class containing the main method -> void: method doesn't return any value -> main: the name of the method For examp...