Java defines Map constants, List constants, and map constants.
Generally, static code blocks are used. For example:
Public final static Map map = new HashMap (); static {map. put ("key1", "value1"); map. put ("key2", "value2 ");}
The following is a simple method for defining Map constants.
Public final static Map <String, Fragment> NAV_ITEM_ADPTER = new HashMap <String, Fragment> () {put ("record transfer", new CameraFragment ()); put ("cluster intercom", new GroupTalkFragment (); put ("video communication", new VideoCallFragment (); put ("location", new PositionFragment ()); put ("Browse", new BrowseFragment (); put ("message", new MsgFragment (); put ("group", new GroupFragment ()); put ("set", null); put ("exit", null );}};
List can be defined as follows:
Public final static List <String> LIST = Arrays. asList ("one", "two", "three ");