/Get Started With Java

Get Started With Java

Let’s get started with a hello world java program and see how programming with java is fun.

A Simple program printing “hello world” in java.

 

class Hello{

private static String s=”hello world”;

public static void main(String args[]){

System.out.println(s);

}

}

 

Now, Let’s get in depth of this program and see what it does.

Java is a completely oops based language , so every program in java is within a class, here class is the keyword used to declare a new class.

you can think of class as a container in which all the variables and functions are stored.

here in this program , “Hello” is the name of the class it could be any name according to naming convention of java.

the variable defined asĀ  “s” and the “main” function is inside the class Hello.

the variable “s” has a value “hello world” assigned to it.

Now, let’s talk about the main function

the main function uses a “public” keyword which is a access specifier, you can think of public as something which can be accessed anywhere even outside the class.

“static” keyword is used to call a function without creating the object of the class.

“void” keyword is used as it don’t return any value.

and “main” is the function in java from where the execution of program starts.

the one line inside the “main” function

System.out.println(s);

In this line “System” is a class in java, “out” is basically output stream to the console, and “println” is a function used to print a value with next line.

When you will execute this program you will get your “hello world” .