Hello world in Java

Hello world in Java

Hello world in Java






Hello World in Java


 



Although Hello_World code is quite short, it includes several key features which are
common to all Java programs. Let’s closely examine each line of code.
The program starts with these lines:

  /*
     This is the first java code 
     This print Hello World on Screen
    */
  //class "Main" remove with your java file name 

This is the comment  in java, like other programming languages. The content of the comment are ignored by compiler. Comments are useful for programmers.

// it is single line comment, it is also ignored by compiler.


class Main

Class is keyword in java,and it define new class, and Main is name of class,

and it is the Identifier. We define Class in next topics. 

public static void main(String[] argu)

The public keyword is an access specifier, which allows programmers to access

main method anywhere from the code. we read more about Access Specifiers in

next lectures. main() is function in java, (like c/c++), all Java applications

begin execution by calling main() method. static means main() method must call

without any object.


System.out.print("Hello World");

System is a predefined class that provides access to the system, and out is the output stream that

is connected to the console. And print() is used to display string. "Hello world" is our string and we

change to this text.

NOTE: System.out.print() is used to display on terminal, we read other ways in next topics.

Print new Line in Java:

Method 01:




 System.out.println("Hello World");

println() is used to print new line in java. 

Method 02:



 
'\n' is used to print new line in java also.

0 Response to "Hello world in Java"

Post a Comment