私は Java の初心者ですが、ネイティブのタイプセーフな列挙型パターンについて学びたいですか? 誰でも私を助けることができますか?
前もって感謝します..
を使用enum
します。詳細は JLS を参照してください。
i want to know the difference between typesafe enum patterns and native type-safe enum patterns.
A type-safe enum pattern is a design / implementation pattern that provides something similar to native enums. Since, Java 5.0 and later support native enum
types (tutorial link), there is no real need to know how to do this. Just use native enum
types.
If you are curious about how it used to be done, read this: Alternative to enum in Java 1.4
(A native typesafe enum pattern is a contradiction in terms. Java's native enum construct is a first class programming language construct ... not a design pattern.)