java的enum用法示例

avatar
作者
猴君
阅读量:0

enum Season { SPRING, SUMMER, AUTUMN, WINTER }

public class EnumExample { public static void main(String[] args) { Season currentSeason = Season.SUMMER;

    switch(currentSeason) {         case SPRING:             System.out.println("It is spring season.");             break;         case SUMMER:             System.out.println("It is summer season.");             break;         case AUTUMN:             System.out.println("It is autumn season.");             break;         case WINTER:             System.out.println("It is winter season.");             break;     } } 

}

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!