Wednesday, 3 June 2015

Helloworld Example Java

First of all we are going to see an example of hello world:



Java is an object oriented programming language.
First Line public class HelloWorld defines a class called HelloWorld.

public: its a access specifier and if its public then this class is accessible from any where. i.e. from any directory, any package, any application.

class: class is a keyword and which is used to declare a class. Java is an OOP language so each and every thing in java should be inside class.

HelloWorld: HelloWorld is a class name. You can give any name as class .

Note that if a class access specifier is public than it should always saved by className.java
here class name is HelloWorld and its access specifier is public so this Java file should be saved as HelloWorld.java.


public static void main(String[] args): main method is entry point for a Java class. It should be always static.

System.out.println( ): 

System: System is a class of java.lang package
out: out is a static member of System class and is an instance of java.io.PrintStream
println: println is a method of java.io.PrintStream. println method is overloaded to print the message in console.

No comments:

Post a Comment