Re: Generics and Enums



On Jul 29, 1:54 pm, Lew <l...@xxxxxxxxxxxxxxxx> wrote:
Roedy Green wrote:
On Sun, 29 Jul 2007 10:55:27 -0700, "amberar...@xxxxxxxxx"
<amberar...@xxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :

I'm trying to write a generic class that takes an Enum as generic
parameter but
I'm not able to compile it:
------------------------------------
public class Foo<T extends Enum> {

Your class is similar to an EnumSet in terms of its Generics. So I
had a peek at how EnumSet does this

public abstract class EnumSet<E extends Enum<E>> extends
AbstractSet<E>
implements Cloneable, java.io.Serializable

This would allow the OP to eliminate the illegal "T.values()" expression and
just call "values()".

--
Lew

I changed "Foo<T extends Enum>" to "Foo<T extends Enum<T>>" but get
the same error.
I also changed T.values() to just values() but that results in a
compile error
saying it cannot find the method values().

.



Relevant Pages

  • Re: Crash for Armidillo
    ... >> medical software where lives are at stake, and I get a compile error, ... A compile error is akin to ... > your version control system that doesn't compile. ... If you don't have a good collection of data on what parts of a design are ...
    (sci.space.policy)
  • Re: xml documentation
    ... I was creating my first custom control, ... The first compile would be fine. ... would throw a compile error with the "Could Not Copy Temporary Files ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cant find old post - Command Button Visible
    ... it created a compile error. ... to do with the Library 3.6 compile problems I've had? ... It has been a learning experience on this database ... "Joan Wild" wrote: ...
    (microsoft.public.access.security)
  • Problems complieing apache_1.3.31 and SSL
    ... > Final apache compile error message: ... not be in the mod_ssl source tree. ... around it by including a version of ssl_expr_scan.c that does compile. ...
    (comp.unix.solaris)
  • Re: How to Find the Date of Last Change in Inventory
    ... your shoulder and give you a hand. ... I do not get the compile error when viewing the code ... > I should tell you that the only VBA code I know how to write is your ...
    (microsoft.public.access.modulesdaovba)