• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

simple question

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could not get the right answer for my question
why the following code works

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think if you declare the method private, it won't be accessible outside the directory in which the class is.
but if u run in the same directory, any modifier will do.
i am not sure about this but since nobody has given a satisfactory answer, i thought i may try.
bye
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi every body
if you don't write private to mail method still it will work
if you write private to class c then it won't compile but
this code looks fine for me
bye

Originally posted by krishnashu:
[B]I could not get the right answer for my question
why the following code works
[/B]


 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Krishna Shu,

main() is a method. And any access modifier will work with main() method. You can try it wil public, protected, friendly/default/package, private access modifier and it will compile and run.
But from the exam point of view remember that by convention main() method should be public.
Reagrds,
Raj.
 
reply
    Bookmark Topic Watch Topic
  • New Topic