枚舉類enum 構造函數 -- study20180420

  1. public enum EOrderTyper {  
  2.      
  3.     NormalOrder(0"一般訂單"),  
  4.     VDDmoney(50"虛擬訂單"),  
  5.     PDDmoney(51"禮品卡訂單");  
  6.     private int orderType;  
  7.     private String description;  
  8.     private EOrderTyper(int type, String desc) {  
  9.         this.orderType = type;  
  10.         this.description = desc;  
  11.     }  
  12.     public int getOrderType() {   return this.orderType;  }  
  13.     public String getDescription() {  return this.description;  }   
  14. }  
  15. ////
  16. System.out.println(EOrderTyper.NormalOrder.getOrderType());
         //輸出:   0
  17. System.out.println(EOrderTyper.VDDmoney.getDescription());
    //輸出: 虛擬訂單

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章