Monday, July 5, 2010

A sample java program -Beginers Approach


class sample

{

public static void main(String asd[])

{

System.out.println(“salem,Tamil nadu”);

}

}
Executing a java program involves two steps Compiling source code into bytecodes Excecuting the bytecode program using java interpreter

public static void main(String args[])


Defines a method name main. Conceptually this is similar to the main() in C language and C++ language.


public : Its an access specifies that makes the main method to be accessible to all other classes
static: which declares this method as one that belongs to the entire class and not a part of any object of the class.
void : The type modifier states that the main method does not return any values.
String args []: Its an array variable of String variable, which is used to receive the command line arguments while executing

No comments:

Post a Comment