Re: Advanced Java Generics syntax question
Brian Maso <[email protected]> Fri, 15 Feb 2008 13:19:41 -0800
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <20080215211943.DPKZ23987.fed1rmmtao104.cox.net@fed1rmimpo03.cox.net> |
Yup, that did it. That was driving me crazy! Thanks!
Brian Maso
At 01:08 PM 2/15/2008, you wrote:
>Brian Maso wrote:
>>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 ) { ... }
>> ...
>> }
>>
>> }
>>
>>}
>
>Sorry, previous post had following line transposed.
>
>LinkedList<String> lls = new LinkedList<String>() {
> public void add( String s ) { ... }
>};
>
>===================================
>This list is hosted by DevelopMentorĀ® http://www.develop.com
>
>View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com