How to create a static Map of String -> Array

后端 未结 6 758
我寻月下人不归
我寻月下人不归 2021-01-11 10:51

I need to create a static Map which maps a given String to an array of int\'s.

In other words, I\'d like to define something l

6条回答
  •  既然无缘
    2021-01-11 11:33

    public class ExampleClass {
        public final static HashMap consts = new HashMap();
        static
        {
            constants.put("A", "The Letter A");
            constants.put("B", "The Letter B");
            constants.put("C", "The Letter C");
        }
        /* Rest of your class that needs to know the consts */
    }
    

提交回复
热议问题