Hello Program

Posted by
class Hello
{
      public static void main(String java[])
      {
               System.out.println("hello everyone");
      }

}

Explanation: All java application begin by calling main() method (just like
c/c++). The  public keyword
is an access specifier, which allows the programmer to control the
visibility of class members.When a class member is preceded by public, then
that member may be accessed by code outside the class in which it is declared.
In this case, main( ) must be declared as public, since it must be
calledby code outside of its class when the program is started. The keyword
static allows main( ) to be called without having to instantiate a
particular instance of the class. This is necessary since main( ) is
called by the Java interpreter before any objects are made.
     The
keyword void simply tells the compiler that main( ) does not return a value. 

        Java
is case sensitive language. So it will give error if you type Main instead
of main, but remember java compiler will still compile your class while
java interpreter would report an error.
         In
main there is a parameter String java[],which is an instance of class String.
       Next
statement is System.out.println(“hello everyone”); System is a
predefined class which provide access to System,standard input,Standard
output,error output stream.
     out
is a field of System class.System class provides three field: static
InputStream in,static PrintStream out,static PrintStream err.
      println
is a method in PrintStream class.PrintStream has following overloaded methods:
 PrintStream.println(),PrintStream.println(boolean),PrintStream.println(char), PrintStream.println(char[]),PrintStream.println(double),PrintStream.println(float), PrintStream.println(int),PrintStream.println(long),PrintStream.println(java.lang.Object), PrintStream.println(java.lang.String)
to write each type on console.
  

Leave a Reply