accessibility

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

accessibility

 
0
  #1
Feb 9th, 2005
Let's say I have two classes, Class1, and Class2.....
Class2 creates and instance of Class1 and calls one of it's methods like this:

  1. Class 2
  2. {
  3. Class1 c1 =new Class1();
  4. c1.myMethod();
  5. }

Now, that would work...But, could you have just the class variable instead of the class instance variable like this:

  1. Class 2
  2. {
  3. Class1.myMethod();
  4. }

Or would that not work...What I was thinking, was in order to do that, Class1 would have to be static..Right?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: accessibility

 
0
  #2
Feb 10th, 2005
Unless myMethod() is static it can only be called on an instance of the class it is defined in.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: accessibility

 
0
  #3
Feb 10th, 2005
Thank you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC