File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generic Inner class doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Generic Inner class doubt" Watch "Generic Inner class doubt" New topic
Author

Generic Inner class doubt

Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Hi,

I am studying to get strong in the use of Generics and I came into a doubt regarding the use of generic inner classes:

This is my test program:


The code compiles and runs as expected for //1 and //2.

These are the compiler messages for //3:


This one is for //4:


What is worng with those lines? How can I instantiate my inner class?

I know this problem may be beyond the actual exam level, but i would really appreciate if someone could point me to the right direction.

Thank you very much.


SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Brian Spindler
Greenhorn

Joined: May 17, 2007
Posts: 29
Code compiles fine on my machine (JDK 1.5.0_08) and produces the following output:

Outer--> One
Outer--> Two
Inner--> Two - One
Inner--> Two - Two
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Strange. I am using JDK 1.5.0_11 (+ console) and still getting the same errors.

But, it certainly did work this morning at home where I was using Eclipse and JDK 1.5.0_10. Are you using Eclipse too? Or is this an 'issue' with JDK 1.5.0_11?
Brian Spindler
Greenhorn

Joined: May 17, 2007
Posts: 29
Using eclipse too.
John Stone
Ranch Hand

Joined: May 04, 2007
Posts: 332
in eclipse fine, in command line errors.
I have javac 1.6.0_01, in eclipse using "compiler compliance 5.0", in console "-source 1.5"
John Stone
Ranch Hand

Joined: May 04, 2007
Posts: 332
found this:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6557954
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Thank you John and Brian.
[ May 30, 2007: Message edited by: Sergio Tridente ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generic Inner class doubt
 
Similar Threads
help me for this question... (interface question)
Question on Reference assignment for Interface references..
References and casting
Interfaces?
I can't find out what's wrong in this code (regarding generics)