Multiple Enum Classes in one Java File

前端 未结 1 844
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 06:18

I have 3 String arrays with constants. eg:

 String[] digit = {\"one\", \"two\", \"three\"};
 String[] teen= {\"ten\", \"twenty\", \"thirty\"};
 String[] anchors          


        
相关标签:
1条回答
  • 2021-02-04 07:00

    They can be three inner classes like this:

    public class Types {
      public enum Digits {...}
      public enum Teens {...}
      ....
    }
    

    Then refer them Types.Digits.ONE, Types.Teen.TWENTY etc.

    You can also use static imports like this:

    import Types.Digits;
    import Types.Teen;
    

    ..

    in order to have shorter references: Digits.ONE, Teen.TWENTY etc.

    0 讨论(0)
提交回复
热议问题