相当于Java中的PHP的const [重复]

This question already has an answer here:

I am porting a lot of code from PHP to Java (an Android application). Everything is done but I am facing a problem here,

I got this PHP code:

class SenderKeyGroupData{
  const MESSAGE = 1;
  const SENDER_KEY = 2;
  /* @var array Field descriptors */
  protected static $fields = array(
      self::MESSAGE => array(
        'name' => 'message',
        'required' => false,
        'type' => 7,
      ),
      self::SENDER_KEY => array(
          'name' => 'sender_key',
          'required' => false,
          'type' => "SenderKeyGroupMessage",
      ),
  );

However I want this code in Java, for example I created this Java code:

class SenderKeyGroupData {
    int MESSAGE = 1; // Must be const
    int SENDER_KEY = 2; // Must be const

    // These two Maps must be in the $fields array?
    Map MESSAGE = new HashMap(); //Duplicate conflict here
    MESSAGE.put("name", "message");
    MESSAGE.put("required", false); // Map can't contain booleans?
    MESSAGE.put("type", "7");

    Map SENDER_KEY = new HashMap(); //Duplicate conflict here
    SENDER_KEY.put("name", "sender_key");
    SENDER_KEY.put("required", false); // Map can't contain booleans?
    SENDER_KEY.put("type", "SenderKeyGroupMessage");
}

I described the problems as comments. All ideas are welcome.

Note that the const contain 1 and 2 as value in the constructor, but also get an array assigned. So please give an example instead of pointing it as duplicate.

</div>

I don't really know how and where you need to access these variables or how you intend to use this class but this at least compiles:

class SenderKeyGroupData {

    public static final int MESSAGE = 1;    // final keyword means it cannot be changed
    public static final int SENDER_KEY = 2; // public keyword means it can be accessed by anyone

    static Map MESSAGE_MAP = new HashMap(); // static means this is shared between all instances
    static {
        MESSAGE_MAP.put("name", "message");
        MESSAGE_MAP.put("required", false);
        MESSAGE_MAP.put("type", "7");
    }

    static Map SENDER_KEY_MAP = new HashMap();
    static {
        SENDER_KEY_MAP.put("name", "sender_key");
        SENDER_KEY_MAP.put("required", false);
        SENDER_KEY_MAP.put("type", "SenderKeyGroupMessage");
    }
}