Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generic Inner class doubt

 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Brian Spindler
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using eclipse too.
 
John Stone
Ranch Hand
Posts: 332
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 332
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you John and Brian.
[ May 30, 2007: Message edited by: Sergio Tridente ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic