Witam, załóżmy że stworzyłem skomplikowaną wielowymiarową tablicę. I chcę wyświetlić wszystkie jej elementy. Czy istnieje prostszy sposób niż ten który wymyśliłem?
int[][][][][] crazy = {
{
{
{
{1,2,3}
}
},
{
{
{4, 5, 6}
}
}
},
{
{
{
{7,8,9}
}
},
{
{
{10,11,12},
{13,14,15}
},
{
{15, 16, 17}
}
}
}
};
for(int firstDimention = 0; firstDimention < crazy.length; firstDimention++)
{
for(int secoundDimention = 0; secoundDimention < crazy[firstDimention].length; secoundDimention++)
{
for(int thirdDimention = 0; thirdDimention < crazy[firstDimention][secoundDimention].length; thirdDimention++)
{
for(int fourthDimention = 0; fourthDimention < crazy[firstDimention][secoundDimention][thirdDimention].length; fourthDimention++)
{
for(int fifthDimention = 0; fifthDimention < crazy[firstDimention][secoundDimention][thirdDimention][fourthDimention].length; fifthDimention++)
{
System.out.println(crazy[firstDimention][secoundDimention][thirdDimention][fourthDimention][fifthDimention]);
}
}
}
}
}