File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Method Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Method Access" Watch "Method Access" New topic

Method Access

Malk Boy

Joined: Feb 17, 2005
Posts: 1
My question is how do I access the methods of the engine class in the control class when I pass an object car to control.

Thanks for any help

public class Car
Engine e;

public car ()
e = new Engine();

public static void main ( String[] args )
Car c = new Car();
Control ctrl = new Control ( c );
marc weber

Joined: Aug 31, 2004
Posts: 11343

Just connect the dots: CarRef.EngineRef.method();

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
marc weber

Joined: Aug 31, 2004
Posts: 11343

As an aside, note that this version of Car could be streamlined to...
I agree. Here's the link:
subject: Method Access
Similar Threads
object hierarchy problem
UML Relations & Java Implementation
Accessing enclosing class method from inner class