aspose file tools*
The moose likes Beginning Java and the fly likes Calling inner classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling inner classes?" Watch "Calling inner classes?" New topic
Author

Calling inner classes?

Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 99
I'm following the oracle training guide as best i can, trying to play with inner classes though and i'm lost. I'm having problems at line 47. how do i call and use innner classes?

Thanks for all your help guys, it means a lot.

vehicle.java


taxi.java


cab.java

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Rob Brew wrote:... I'm having problems at line 47. how do i call and use innner classes? ...

I think your problem is actually at line 64.

An instance of an inner class (Speedo) always needs to be associated with an instance of the enclosing class (taxi). This means you need an instance of taxi before you can create an instance of Speedo. So instead of just...

...create a new instance of taxi first, then use that instance to create a new Speedo...


Edit: Note that if you already have an instance of the enclosing class, then you could simply use that. For example...


"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
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling inner classes?