How to print data from a jagged array by using for each loop
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 19, 2014, 12:55 PM EDT
http://www.c-sharpcorner.com/Forums/Thread/249315/how-to-use-jagged-array-in-java.aspx
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < i + 1; j++)
{
System.out.print(jagged[i][j] + " ");
}
System.out.println();
}
The output is:
0
1 2
3 4 5
6 7 8 9