1

Instead of this:

int[][] someArr = { { 88, 35 }, { 11, 98 } };
mapDE = new HashMap<String, int[][]>();
mapDE.put("someKey", someArr);

I would like to do this in order to save a code of line:

mapDE = new HashMap<String, int[][]>();
mapDE.put("someKey", { { 88, 35 }, { 11, 98 } });

Any easy way to do this?

cocos2dbeginner
  • 2,185
  • 1
  • 31
  • 58

3 Answers3

2

mapDE.put("someKey", { { 88, 35 }, { 11, 98 } }); does not compile because { { 88, 35 }, { 11, 98 } } wont ensure the type int[][]

You could try by this way:

    Map<String, int[][]> mapDE = new HashMap<String, int[][]>();
    mapDE.put("someKey",new int[][] { { 88, 35 }, { 11, 98 } });
rev_dihazum
  • 818
  • 1
  • 9
  • 19
1

Use this:

mapDE.put("somekey", new int[][]{
  { 0, 0 },
  { 0, 0 } });
Jeffalee
  • 1,080
  • 1
  • 7
  • 15
1

You're very close, try the following:

mapDE.put("someKey", new int[][]{{88, 35}, {11, 98}});
ck1
  • 5,243
  • 1
  • 21
  • 25