自定義列舉

2021-09-24 12:24:34 字數 548 閱讀 1696

在效能優化中,列舉的每乙個都是乙個例項,比較耗記憶體,採用自定義註解能很好的解決這個問題

public

class

shape

)//表示表示需要在什麼級別儲存該注釋資訊,用於描述註解的生命週期

@retention

(retentionpolicy.runtime)

public @inte***ce

model

//預設的值

private

@model

int value = rectangle;

public

void

setvalue

(@model

int value)

public

intgetvalue()

}

使用
shape sp = new shape();

sp.setvalue(square|shape.circle);

sp.getvalue();

自定義列舉特性

新增乙個列舉擴充套件類 列舉擴充套件特性 attributeusage attributetargets.field attributetargets.enum public class apienum attribute set public string message set 列舉特性 訊息碼...

學習 自定義排序 列舉定義實現

實體 重點comparable引數 data equalsandhashcode callsuper false public class statisticviewvo extends baseentity public comparator sort sort s public enum sor...

自定義型別(結構,列舉,聯合)

eg struct tag tag結構體標籤 char name 10 名字 int age 年齡 char gender 3 性別 分號不能丟 在結構體宣告的時候,可以省略結構體標籤tag 2.結構體的成員 標量,陣列,指標,甚至其他結構體 3.結構體成員的訪問 1.結構體是通過點操作符 訪問的,...