5

I want to create multidimensional array which has levels, groups and items.

2
  • 1
    Check it out this link.... stackoverflow.com/questions/5176512/… Commented Aug 5, 2011 at 7:10
  • @Uttam,Thanks for post link, i am going to check Commented Aug 5, 2011 at 7:16

2 Answers 2

11

Why not create an array of your custom defined objects?

class A{
    int t;
    int b;
}

List<A> test = new ArrayList<A>();
test.add(new A());
Sign up to request clarification or add additional context in comments.

4 Comments

how to get values form this once passed to somewhere else?
Just as normal objects. test[0].t . Ob cource it is good practice to use encapsulation, add public int getT(), public int getB() and not access the fields directly.
How to set value
just as normal objects: test[0].t = 123 or preferably add a constructor to A
4

To create Multidimensional array in static way,

Ex:

static final String listdesc[][][][] =
{
    { // grey
      {  // lightgray
        { "grey", "grey only" },
        { "lightgrey","#D3D3D3" },
        { "dimgrey","#696969" }
      },
      {  // darkgray
        { "grey", "darkgrey" },
        { "sgi grey 92","#EAEAEA" }
      }
    },
    { // blue
      {  // lightblue
        { "blue", "lightblue" },
        { "dodgerblue 2","#1C86EE" }
      },
      {  // darkblue
        { "blue", "darkblue" },
        { "steelblue 2","#5CACEE" },
        { "powderblue","#B0E0E6" }
      }
    },
    { // yellow
      {  // lightyellow
        { "yellow", "lightyellow" },
        { "yellow 1","#FFFF00" },
        { "gold 1","#FFD700" }
      },
      {  // darkyellow
        { "yellow", "darkyellow" },
        { "darkgoldenrod 1","#FFB90F" }
      }
    },
    { // red
      {  // lightred
        { "red", "lightred" },
        { "indianred 1","#FF6A6A" }
      },
      {  // darkred
        { "red", "darkred" },
        { "firebrick 1","#FF3030" },
        { "maroon","#800000" }
      },

    }
};

To create it programatically, refer to,

Assign data to a four Dimensional Array at RunTime

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.