aspose file tools*
The moose likes Beginning Java and the fly likes Inner classes in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inner classes in Eclipse" Watch "Inner classes in Eclipse" New topic
Author

Inner classes in Eclipse

Liz Carter
Greenhorn

Joined: Jan 05, 2009
Posts: 6
I am half way in Head first java.. and trying out the pool puzzle on page 396. for the amazing shrinking blue rectangle.

I am using eclipse to complie and run my programs. but it doesnt seem to recognize the inner class MyDrawP. I am getting the error MyDrawP cannot be resolved to a type. Please let me know where I am making the mistake?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

It will be quicker to help you if you post the code.


[My Blog]
All roads lead to JavaRanch
Liz Carter
Greenhorn

Joined: Jan 05, 2009
Posts: 6
Ok here goes...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

(I have enclosed your source with a "code" tag. Please use it the next time you post some code.)

You have declared the inner class inside a method. I don't know how the code looks in your book, but if you want to use an inner class that way, you'll have to declare the class before using variables of that class. Like this :


Are you sure that the MyDrawP class is inside the go() method ?
Liz Carter
Greenhorn

Joined: Jan 05, 2009
Posts: 6
Declaring the inner class before the variables removed the error. Thanks.

and yes the inner class is declared in go() and it is given at the end of the method in the book.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19542
    
  16

Are you sure the book didn't declare the class just after the method, instead of at the end inside?


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: Inner classes in Eclipse
 
Similar Threads
JDeveloper using xmlBeans inner interfaces
debugging with tomcat
project build
cannot find the declaration of element taglib
JMX WEB console acess