File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Regrding Access Specifier used of main method
Joined: Jan 25, 2006
Mar 16, 2006 11:17:00
I want to know what is the significance of public access modifier with main (
args) method. Like generally we write
public static void main(String args)
But if we write
private static void main(String args)
protected static void main(String args)
then also its working properly.............
then what is the use of public keyword..........................
Ajay Pratap Singh
Joined: Feb 07, 2005
Mar 16, 2006 11:39:00
It works properly when compiling.
But have you tried running the program that doesn't have the keyword public in the header of the main method?
Joined: Aug 31, 2004
Mar 16, 2006 11:44:00
1.4, main methods are required to be public in order to be program entry points (i.e., run from a command prompt).
A non-public method called "main" is perfectly valid -- it just can't be used as a program entry point.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award."
subject: Regrding Access Specifier used of main method
Help Me...Doubt in Overloading..
Static Variable Problem
can somebody explain this?
What is the main usage of "String args" in public static void main(String args)?
Why we pass string object to main?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014