Download presentation
Presentation is loading. Please wait.
1
2D Array TA.Rawan
2
Print 2D array This Photo by Unknown Author is licensed under CC BY-SA-NC
3
Initialize 2D Array: “twodArray ”
int [][] twodArray ={ {2,1,5}, {32,5,4} }; Column j[0] j[0] j[1] j[1] j[2] i[0] 5 1 2 4 32 ROW i[1]
4
Which means length of row in this example for first row = 3
To print 2D Array: Which means length of row in this example for first row = 3 for (int i = 0; i < twodarray.length; i++) { for (int j = 0; j < twodarray[i].length; j++) System.out.print(twodarray[i][j] + “ ” ); } System.out.println();
5
To print 2D Array: i=0 j=0 j=0 j=0 Is j <3 Is j <3 j=1
Is i<2 j=0 j=0 j=0 Is j <3 Is j <3 j=1 Is j <3 j=2 Is j <3 j=3 Is j <3 j[0] j[1] j[2] i[0] 2 1 5 Repeat the same steps for i=1, then when i= 2 the condition is false 2<2
6
Thank you. Any questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.