Sign in to follow this  
Followers 0
chetanaforum

Explain : public static void main(String[] args)


Question of the Day :- 19 March 2006

----------------------------------------------------------------

Explain all words in the statement public static void main(String[] args)

----------------------------------------------------------------

Share this post


Link to post
Share on other sites

Hi,

public static void main(String[] string)

public - This access modifier makes this method accessible everywhere.

static - It will make this main method invokable without creating an instance of this class.

void - void declares that the method does not return any value.

main - it is a thread which the JVM looks first and is the entry point for the program

Sting[]- that is java will accept every thing as a string array.

string - This defines a parameter to the main method and will accept command line options passed by the user while invoking the progam.

An simple example:

class best

{

public static void main(String[] s)

{

System.out.println("good");

}

}

Share this post


Link to post
Share on other sites
Public is Access Specifier it means The Method(Function) Can Be Accessed From Any wherestatic is type of Storage class it implies That the Memory Allocated To main, Will Be Remain Held on complition of Main method too..void means EmptyMain Is The main Function()String Is keyword for String args is An Instance Which Is Type String Passed to Main()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0