« Home | Delete and Update values in MySql Using Java » | Insert values into table Using Java » | Program to Retrive values from Mysql Using Java » | Java Mysql Connectivity » | Program to Delete Files in a Given Directory » | Program to Write to a file » | Program to Rename Files in a given Directory » 

Friday, March 10, 2006 

Public static void main (String args[])

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 called by 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. As you will see, methods may also return values.
As stated, main( ) is the method called when a Java application begins. Keep in mind that Java is case-sensitive. Thus, Main is different from main. It is important to understand that the Java compiler will compile classes that do not contain a main( ) method. But the Java interpreter has no way to run these classes. So, if you had typed Main instead of main, the compiler would still compile your program. However, the Java interpreter would report an error because it would be unable to find the main( ) method.
Any information that you need to pass to a method is received by variables specified within the set of parentheses that follow the name of the method. These variables are called parameters. If there are no parameters required for a given method, you still need to include the empty parentheses. In main( ), there is only one parameter, albeit a complicated one. String args[ ] declares a parameter named args, which is an array of instances of the class String. Objects of type String store character strings. In this case, args receives any command-line arguments present when the program is executed.

nice info .. thnks

Yes Indeed Nice & Detailed info! Thanks :)

This comment has been removed by the author.

really nice info.....my doubt got clarified..thanks

this didn't help at all. why don't programmers speak in ways i can understand...

The keyword static allows main( ) to be called without having to instantiate a particular instance of the class.

Wht u understand by the given statement..???
Wht u understand by the instance of the class????


Kindly reply me asap vishalb1204@gmail.com

It was nice n detailed........thnks

thanks for this useful info

Thanks men, i was a c++ guy and was wondering what the hell all these details were, i think this will give me a headstart with java, edu

it's good info

Nice information!!!

Thank U...

really nice

Well framed!!!

i gives very important info.

excelent information

Im a beginner for JAVA.
This is so useful and easily to understand. thanks for the info =)

this is what many books hane failed to write,indeed a great note.

nice piece if info.
thanx...

it was a very useful info..thanks

thanks nic info:)

It is very useful for java learners..............thanQ

It is very useful for java learners..............thanQ

It is very useful for java learners..............thanQ

good one dude..!!

good details dude.

why execution of prograam start from main method?and why main is public

why execution of prograam start from main method?and why main is public

informative blog......keep it up

nice....
but I cant understand that why we cant pass arguments as 'int' or 'char' or anyother and only 'String' ?
Please reply on shashwat.mehta91@gmail.com

thanks for the info..it would be more helpful if i come to know the use of 'String args[]'...

thanks for the info...it would be more helpful if i come to know the use of 'String[] args'

y string s used in command line,instead of string while we use int,float we are getting error report,why?

copied from complete reference book of herbert....but thx.....Read books guys

it is very use full to understand the necessity of public before main method. Thank you:>>

use full information for java beginners

really nice information for java beginners..

really nice for java beginners..thanks..:)

it becomes more easier 4 the beginers of java candidates.....

Very well explained.

Very well explained.

I will thank u only if u will give the answer of my ques. Is "public static void main(String [] args)" user defined or pre defined??????

Click to view meaning of public static void main(String args[]) in details.

Post a Comment

About me

  • I'm phanindra
  • From Hyderabad, Andhra Pradesh, India
  • An Alumini of JNTU Hyd into happening IT industry...
My profile

Visitors
Bloggeries Blog Directory BlogRankings.com singapore blog directory blog search directory
Google
 
Web conceptoftheday.blospot.com