Java遍历枚举(Enum)的Value和相对应的Index

遍历枚举:

public class ColorIndexTest {

    @SuppressWarnings("resource")
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        HSSFColorPredefined[] allColor = HSSFColorPredefined.values();
        for(int i = 0;i < allColor.length;i++) {
            System.out.println(allColor[i].name() + " == " + allColor[i].ordinal());
        }
    }
}





你可能感兴趣的:(Java)