This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling inner classes?" Watch "Calling inner classes?" New topic

Calling inner classes?

Rob Brew
Ranch Hand

Joined: Jun 23, 2011
Posts: 101
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.

marc weber

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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Calling inner classes?
It's not a secret anymore!