/** * Enumeration for the message delivery mode. Can be persistent or * non persistent. Use the method 'toInt' to get the appropriate value * that is used the he AMQP protocol instead of the ordinal() value when * passing into AMQP APIs. * * @author…
Java1.5 中出现了枚举类型.当一个值都在一个固定的范围内变化,那就可以使用 enum 类型来定义.比如说,一周有七天,一年有四季. 没有枚举类的时候,我们用常量来定义一组范围值的: public static class Season { public static final int SPRING = 1; public static final int SUMMER = 2; public static final int AUTUMN = 3; public static final…
Class定义常量方法(推荐方法) //final修饰符 public final class Constants { //私有构造方法 private Constants() {} public static final int ConstantA = 100; public static final int ConstantB = 100; ...... } 采用“类.常量名”方法进行调用.需要私有化构造方法,避免创建该类的实例.同时不需让其他类继承该类. 如果多处需要访问工具类中定义的常量…