JAVA programs

Java program to print text on screen- "Hello world" Text

It is first program for learners of java language, in this program Plane text is print on screen.

To print the text on screen System.out.println() function is used.

How to Run:

To run this program using notepad editor save file with name on disk.

Use javac command to compile program.

For Ex:

 C:\Users\java programs>javac

And to run program:

C:\Users\java programs>java First

Note that File name and the class name should be same in java.



class First


    public static void main(String args[])


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




When Run The Program Following Output:

Hello World


In above program we created the class named First.

Java Program start their execution from the main() method so main() written in class.

main() should be declared as public static void main()

public: accessible outside the class

static: only one copy created of main() so it is static method

void: main() does not return any value so it is void return type is given

to print line on screen we use statement  System.out.println() string value should be passed in this function.

Releted Programs

© 2017 codewmAll rights reserved. (by Wallipasha Mujawar)