先学习C/C++转而学习JAVA的朋友可能觉得JAVA没有enum类型很不方便. 这个问题其实可以通过Interface来解决:
比如定义一个Interface:
public interface Animal
{
int DOG = 1, CAT = 2, TIGER =3, SNAKE = 4;
}
public class Test implements Animal
{
public Test();
public boolean isDog( int animal)
{
return (animal == DOG) ? true : false;
}
}