基本方向(北、東、南、西)の列挙型クラスがあります。
public enum Direction {
NORTH,
EAST,
SOUTH,
WEST;
}
同じものに複数の名前を使用できる方法はありますか? たとえば、次のようなものです。
public enum Direction {
NORTH or N,
EAST or E,
SOUTH or S,
WEST or W;
}
実際には、私が望むのは、N または NORTH のいずれかの変数に署名して、2 つの操作をまったく同じにすることです。
例:
Direction direction1=new Direction.NORTH;
Direction direction2=new Direction.N;
//direction1==direction2