Home php How to implement an associative array on java?

How to implement an associative array on java?




Trying to implement This PHP code on java . How someone wrote in the comments is

$ table = array (
  0x83 = & gt; 0x00C9, 0x84 = & gt; 0x00d1, 0x87 = & gt; 0x00e1, 0x8e = & gt; 0x00e9, 0x92 = & gt; 0x00ED,
  0x96 = & gt; 0x00F1, 0x97 = & gt; 0x00f3, 0x9c = & gt; 0x00fa, 0xe7 = & gt; 0x00c1, 0xea = & gt; 0x00CD,
  0xee = & gt; 0x00d3, 0xf2 = & gt; 0x00da.

Associative array. There are no such java. How to implement it?

Answer 1, Authority 100%

Implementing an array on java .

hashmap & lt; integer, integer & gt; AssociativeArray = new hashmap & lt; & gt; (13);
  AssociativeArray.put (0x83, 0x00C9);
  AssociativeArray.put (0x00d1, 0x87);
  AssociativeArray.put (0x87, 0x00e1);
  AssociativeArray.put (0x8e, 0x00e9);
  AssociativeArray.put (0x92, 0x00ED);
  AssociativeArray.put (0x96, 0x00f1);
  AssociativeArray.put (0x97, 0x00f3);
  AssociativeArray.put (0x9c, 0x00fa);
  AssociativeArray.put (0xe7, 0x00c1);
  AssociativeArray.put (0xea, 0x00CD);
  AssociativeArray.put (0xee, 0x00d3);
  AssociativeArray.put (0xF2, 0x00da);

Answer 2

Hold your function code on the knee, did not check but it should work everything, how to fill the array you have already shown.

Public String GetCodes (String Code) {
  Hashmap & lt; String, String & GT; Hexcodes = New Hashmap & LT; String, String & GT; ();
  String Val = Hexcodes.get (Code);
  RETURN VAL.REPLACE ("0x", "& amp; #x")

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions