This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 19685
    
  20

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