Google+ Explain : public static void main(String[] args) - SUN SPECIAL - JAVA, J2EE - ChetanaSforum

Jump to content


Photo

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







  • Please log in to reply
2 replies to this topic

#1 ChetanaS






Posted 18 March 2006 - 10:56 PM

- PLEASE SHARE

Question of the Day :- 19 March 2006
----------------------------------------------------------------
Explain all words in the statement public static void main(String[] args)
----------------------------------------------------------------


#2 kavin

kavin

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 20 March 2006 - 09:24 AM

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 [b]main(String[] s)
{
System.out.println("good");
}
}

#3 Harish M

Harish M

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 12 May 2006 - 07:31 PM

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()