I have the following function:
I want to use the two commented out lines instead of the longer block of code below it.
If I uncomment the lines, it gives me an error about the '.' after EnumSet<E>. I haven't been using Generics (or Java) for very long, but I can't see what the problem is?
Code:
private static <E extends Enum<? super E>> boolean IsValueInEnum( E value,
E[] values )
{
// EnumSet<E> eSet = EnumSet<E>.range( values[0], values[values.length] );
// return eSet.contains( value );
for ( E en : values )
{
if ( en == value )
{
return true;
}
}
return false;
}
If I uncomment the lines, it gives me an error about the '.' after EnumSet<E>. I haven't been using Generics (or Java) for very long, but I can't see what the problem is?