Java枚举

xiaoxiao2021-03-01  14

 

 

public enum TransportType { TCP(0), UDP(1), TLS(2); private int value; TransportType(int value) { this.value = value; } public int getValue() { return value; } public void setValue(int value) { this.value = value; } public static TransportType getInstance(int transportType) { switch (transportType) { case 0: return TransportType.TCP; case 1: return TransportType.UDP; case 2: return TransportType.TLS; default: return TransportType.TCP; } } }

 

相关资源:Java枚举类使用场景及实例解析
转载请注明原文地址: https://www.6miu.com/read-3649946.html

最新回复(0)