• Post Reply Bookmark Topic Watch Topic
  • New Topic

static main method  RSS feed

 
Thiagu Gopal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1> Why can't we call main method as like other static methods ?
ex:
Circle.main("56");
2> It is possiple to give access modifier to our object reference
ex:
private Circle c=new Circle();
3>
[ July 07, 2006: Message edited by: Thiagu Gopal ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1> You can call it, as long as you pass a array of String.
2> sorry I don't understand what you mean
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. null can also be passed to main

2. You can make class level references private. References that exist only inside a method are already specific to that method.
[ July 07, 2006: Message edited by: Rusty Shackleford ]
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thiagu Gopal:
1> Why can't we call main method as like other static methods ?
ex:
Circle.main("56");
2> It is possiple to give access modifier to our object reference
ex:
private Circle c=new Circle();
3>

[ July 07, 2006: Message edited by: Thiagu Gopal ]



Wel Answer 1: Ofcourse We can call any other class's main method I just show you an example just run this one:



Save this file as "Sample.java" and run it, it will also call main method of Abc Class.


We Now Come to IInd Question, Yes it is possible
It is possible to give access modifier to our object reference


You can try an example ownself and then check.

Hope this helps you.

 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post the same question twice. it wastes people's time when they answer a question that has already been answered elsewhere.

i have closed the other thread, so all followups should go here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!