Stopping repetition in Java enums

后端 未结 4 1554
梦谈多话
梦谈多话 2020-12-03 16:26

I have the following enum in a Java class:

public enum Resolution {
    RES_32 (32),
    RES_64 (64);
    private final int asInt;
    private R         


        
4条回答
  •  萌比男神i
    2020-12-03 17:11

    I would add the new value to the original enum and have the new classes just re-use it. Why can't they call the first one you posted? You have bigger issues than merely repeating a constructor if you copy and extend the first one.

提交回复
热议问题