zoukankan      html  css  js  c++  java
  • java枚举使用

    1.开发中如何使用枚举,一般在开发中使用消息提示。枚举可以继承,实现接口等。
    public enum Result { SUCCESS(1,"201 ok") { @Override void doCallBack(String msg) { System.out.println("201 success process!!!" + " " + msg); } }, ERROR(2,"501 server error") { @Override void doCallBack(String msg) { System.out.println("server error process !!!" + " " + msg); } }, FAIRL(3,"javascript error") { @Override void doCallBack(String msg) { System.out.println("javascript error process!!!" + " " + msg); } }; private int code; private String msg; abstract void doCallBack(String msg); Result(int code,String msg){ this.code = code; this.msg = msg; } public static void main(String[] args) { Result v = Result.ERROR; v.doCallBack(v.msg); } }

      

  • 相关阅读:
    代理模式
    适配器模式
    策略模式
    原型模式
    内存溢出
    jvm常用参数
    单例模式
    抽象工厂
    工厂方法模式
    选择器代码
  • 原文地址:https://www.cnblogs.com/gstsyyb/p/5080595.html
Copyright © 2011-2022 走看看