hello java - the first java program

print a string on consol using java

Category: Java J2SE Tags: Java, Java J2SE

Start with Java :

class Hello
public static void main(String[] args)
System.out.println("Hello Java");

        The class name Hello. In java everything has to be in a class, even the main function must be defined inside class. in order to define a program, a class must include a method called main, like:

public static void main(String[] args)
explanation :-
public : public is a keyword makes main as public to be available outside the class.
static : no object required to call the function main.
void : no return value.
main : name of function, must be defined inside class.
String[] args : arguments to function main, String is a class, args is name of array of string class type can be any name.
System.out.println :- System is inbuilt class, out is static object of this class and println is method name, used for print a line on console.
Hello Java :- "Hello Java" is argument to println method.

Compile & Run :- Now you have to install JDK(java development kit) on your machine and have to set the path. you can find no google how to set the path.

After all done, open command prompt and target the directory where your program file(You have to make this code in notepad and save this code with classname.java like in above class name is Hello, so u would save the file with name Hello.java) is saved.then type command javac Hello.java(javac for java compiler) for compile the program. and after successfully compile, type the command java Hello(for run the program).

Output :- Hello Java

Like 0 People
Published on 28 August 2013
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 136
Questions: 12
Given Best Solutions: 12 *


And every class must be uppercase, this is one of little disvantages versus scripting languages as VBScript
Like 0 People on 2 December 2013

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User