I have create following string multidimensional array in java. which has top outer array is level(6 levels)and under each level has 4 different sub-level(4 sub levels) and each group has individual 10 set ,that have head and tails.I want to access level1->>sublevel1->set1–>head and tails …level3->group4->set7->head and tails and so on up to level6->sublevel4->set10->head and tails.
final String[][][][] myStr = {
{
{
{"it", "it was over"},
{"on","work on it"},
},
{
{"very", "very good girl"},
{"all","all around"},
},
{
{
{"for", "good for you"},
{"are","are so long"},
},
{
{"with","with his cat"},
{"it", "it was over"},
}
},
...
{
{
{"get","get the cat"},
{"for", "good for you"},
},
{
{"on","work on it"},
{"can","can come here"},
},
{
{"as","as long as"},
{"but", "but not me"},
},
{
{"aunt","was my aunt"},
{"system", "her system was"},
}
}
};
Help me this problem , i think which is great appreciate to me.
Whatever your problem is, you shouldn’t use such a kind of array, because your code will be impossible to understand and unmaintainable.
You should create a
Levelclass, which would give access to a set or list ofSubLevelinstances, which should give you access to a set or list ofGroupinstances, etc.This will lead to much more readable code, and allow you to encapsulate behavior in these classes.