Two Laptop Bag*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instantiate a inner class object" Watch "Instantiate a inner class object" New topic
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instantiate a inner class object
 
Similar Threads
inner classes and encapsulation
Basic GUI problem :(
Meaning of Declaring an object as private and static
Initializing method local String object.
Im having an errror