jdk1.8使用枚舉類
阿新 • • 發佈:2019-05-14
bsp map enum 巴巴 array public each stream web
package com.mq; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public enum ChannelEnum { WEBB("15","威客巴巴"), CMM("19","菜嬤嬤"); private String channelCode; private String channelName; ChannelEnum(String channelCode, String channelName) {this.channelCode = channelCode; this.channelName = channelName; } public static final Map<String, String> channelEnumMap = new HashMap<>(); static { Arrays.stream(ChannelEnum.values()).forEach(e->channelEnumMap.put(e.getChannelCode(),e.getChannelName())); }public String getChannelCode() { return channelCode; } public String getChannelName() { return channelName; } public void setChannelCode(String channelCode) { this.channelCode = channelCode; } public void setChannelName(String channelName) {this.channelName = channelName; } }
jdk1.8使用枚舉類