This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Instantiate a inner class object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instantiate a inner class object" Watch "Instantiate a inner class object" New topic

Instantiate a inner class object

Waria Ahmed
Ranch Hand

Joined: Jul 09, 2008
Posts: 56
Hi there,

I'm teaching myself about inner classes and am just practicing some code to test what I've learnt. Unfortunately I have got stuck instantiating a object, the following is my code. Would be grateful if anyone could assist me:

I get the error on the line where im trying to create a object. Thanks
Rob Spoor

Joined: Oct 27, 2005
Posts: 20083

Your Student inner class is not static. Therefore, as all other non-static members (fields, methods), you will need an instance of the enclosing class first:

Either that, or make the class static.

How To Ask Questions How To Answer Questions
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: Instantiate a inner class object
It's not a secret anymore!