• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main(String arr[])

 
chowdaryv
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam able to call main(String arr[]) from command prompt with having private access modifier.
 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont quite understand the question, I think.But if it is to express the fact that you dont get any errors with main declared as "private", then let it be known to you that this is an inconsistency in the declaration of the method called "main", that Sun admits and documented.It does not agree with the Java Language Specification which stipulates that main has to be declared as public static and void.So in general, the intended behavior was for the compiler to complain if main is defined differently from public static void, but somehow it managed to sneak through and one can successfully make it private and all will be oky.For the sake of conformity to the language specification though, let us consider main as public static void.
Herbert
 
ricky gonzalez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think "private static void main(String [] argv)" is not going to get compiled. Can you post the source code?
Also, static void main(String [] argv) will get compiled and run successfully. I guess all fields are by default public.
Thanks.
 
RAMESHDESHPANDE
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by chowdaryv:
iam able to call main(String arr[]) from command prompt with having private access modifier.

 
RAMESHDESHPANDE
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by chowdaryv:
iam able to call main(String arr[]) from command prompt with having private access modifier.

PLEASE SEND ME THE CODE
BYE,
RAM_DESH@USA.NET
 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does work. Just try it.
 
Sridhar Katakam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Default is 'package' not 'public'
~Sri~
Originally posted by ricky gonzalez:
I think "private static void main(String [] argv)" is not going to get compiled. Can you post the source code?
Also, static void main(String [] argv) will get compiled and run successfully. I guess all fields are by default public.
Thanks.

 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic