How to Print Message in Java | Coding Startup

How to Print Message in Java

How to Print Message in Java



100% Working Code and Projects.if you need any help about project and Application Contact Shelly at:+917888361589.

See the code below :-

Java Code :-

public class Hello {

    public static void main(String[] args) {
        System.out.println("Hello ");
        System.out.print("How are you ? ");
    }

}


Explanation :-

In first line, we have declared the class name which is public. Public is an access specifier which means that we can access it from any where.


In Second line,


  Public
 Access Specifier which can used any where again .
  Static
 Value or data remain unchanged  throughout the program.
  Void
A data type which does not contain any thing or null.
  Main
A function which is entry gate of any java program.
 String
It is a most flexible data type in java.
[] args
It is used because java program is store in array . it is not compulsory that we have to use args we can take any name or variable.













In third line, System is a class which call the another class which is PrintStream.java and that contains the two method which is println() and print(). Out is a object and println() is a method



Now the difference between println and print is that println() will print the message in next line and print() will print the message in the same line.






Output :-
Hello
How are you ? BUILD SUCCESSFUL (total time: 2 seconds)























Code Startup

Author & Editor

0 Comments:

Post a Comment