U
Ulrich Scholz
Dear all,
The following example of EnumTest seems to be inconsitent with the
interface definition of contains: It executes the lines marked with
XXX, which clearly is an error. Does anyone have an explanation?
Thank you,
Ulrich
import java.util.*;
public class EnumSetTest
{
public enum EnumTest
{
ONE,
TWO,
}
public final void testEnumSet()
{
final EnumSet<EnumTest> result = EnumSet.noneOf(EnumTest.class);
if(result.isEmpty())
{
System.out.println("empty"); // enters this branch: correct
}
else
{
System.out.println("not empty");
}
if(result.contains(EnumTest.ONE));
{
System.out.println("error"); // XXX
}
if(result.contains(EnumTest.TWO));
{
System.out.println("error"); // XXX
}
}
}
The following example of EnumTest seems to be inconsitent with the
interface definition of contains: It executes the lines marked with
XXX, which clearly is an error. Does anyone have an explanation?
Thank you,
Ulrich
import java.util.*;
public class EnumSetTest
{
public enum EnumTest
{
ONE,
TWO,
}
public final void testEnumSet()
{
final EnumSet<EnumTest> result = EnumSet.noneOf(EnumTest.class);
if(result.isEmpty())
{
System.out.println("empty"); // enters this branch: correct
}
else
{
System.out.println("not empty");
}
if(result.contains(EnumTest.ONE));
{
System.out.println("error"); // XXX
}
if(result.contains(EnumTest.TWO));
{
System.out.println("error"); // XXX
}
}
}