Advanced Java Generics syntax question

Brian Maso <[email protected]> Fri, 15 Feb 2008 12:56:27 -0800
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <20080215205628.DEZO23987.fed1rmmtao104.cox.net@fed1rmimpo02.cox.net>
I want to define an anonymous subclass of a generic class -- how do I
set the parameter type?

Here's a non-anonymous example of a subclass binding the superclass
type variable:

public LinkedListOfStrings extends LinkedList<String> {
   ...
}

That's no problem. Now let's say I want to do the same thing but with
an anonymous inner class:

class Outer {

   public void someMethod() {

     LinkedList<String> lls = new LinkedList() {  <-- how do I
indicate the superclass is LinkedList<String>?
       public void add( String s ) { ... }
       ...
     }

   }

}

Anjelika Langer is silent on the issue -- which is utterly surprising.

I hope someone knows the answer, because its driving me crazy.

Brian Maso

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com