Java中枚舉的另類用法

定義:

public enum UriSchema { 
        TEL("tel:"), SMS("sms:"), EMAIL("mailto:"), FILE("file:"), REMOTE("remote:"), HTTP( 
         "http:"), GEO("geo:"), LOC("loc:"); 

         private String mValue; 

         private UriSchema(String value) { 
             mValue = value; 
         } 

         public String getmValue() { 
             return mValue; 
         } 
}

=========================================================================

用法:

UriSchema.TEL.getmValue()

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