除了这样做外,还有其它办法吗
public enum Test
{
one(1), two(2), three(3);
private Test(int value)
{
this.value = value;
}
private int value;
}然后这样用
switch (aenum.value)
{
case 1: .....; break;
case 2: .....; break;
}请问还有其它办法吗。
public enum Test
{
one(1), two(2), three(3);
private Test(int value)
{
this.value = value;
}
private int value;
}然后这样用
switch (aenum.value)
{
case 1: .....; break;
case 2: .....; break;
}请问还有其它办法吗。
{
case Test.one: .....; break;
case Test.two: .....; break;
....
}
我怎么看不懂啊
public enum Test 这个是什么意思?难道是java5新引进的?
还有one(1), two(2), three(3);怎么个意思?
然后switch (aenum.value)
这个aenum是从哪里来的?
烦请达人解释一下啊
谢谢啊
难道两个月没看java,我又落伍了。。
enum Test
{
one, two, three;
public static int conv(Test t)
{
int i = 0;
switch (t)
{
case one:
i = 1;
break;
case two:
i = 2;
break;
case three:
i = 3;
break;
}
return i;
}
}
Test t = Test.two;
int i = Test.conv(t);
System.out.println(i);不知对你有没有用