EnumSet + contains: strange behavior
- From: "Ulrich Scholz" <d4@xxxxxxxxxxx>
- Date: 31 May 2006 08:05:37 -0700
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
}
}
}
.
- Follow-Ups:
- Re: EnumSet + contains: strange behavior
- From: Oliver Wong
- Re: EnumSet + contains: strange behavior
- Prev by Date: Re: Debugger and function calls
- Next by Date: Re: Problems with Map.size()..........
- Previous by thread: Making Form results readable
- Next by thread: Re: EnumSet + contains: strange behavior
- Index(es):