aspose file tools
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 Elasticsearch in Action this week in the Big Data 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: 19905

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 agree. Here's the link:
subject: Instantiate a inner class object