• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I get access to methods in other classes

 
Bruce Schmid
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Question, How does a class (A)get access to another classes(B) methods without instantuating the class or inheritance?
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java classes communicate with one another via objects, or instances of objects.
So, in order for Class(A) to access Class(B) method you will need instantiation at
least.

Take a look at this link: http://java.sun.com/docs/books/tutorial/java/javaOO/index.html


GJ

 
Campbell Ritchie
Sheriff
Pie
Posts: 50171
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Anu Pillai
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the method in class B is declared as static, then cant any method from class A call the method in class B without instantiating or inheritence?
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, since static methods are associated with a class rather than with an object instance.

John.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic