Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String[] args) {
- int[][] ints = {{1,2,3,4,5},{6,7,8,9,0}}; // initialize our mda which is on index[0] values is (1,2,3,4,5) and index[1] values is (6,7,8,9,0)
- for(int x=0;x<ints.length;x++){ // now this loop will iterate depends on the length of the mda which is 2 starting count of 0 to 1 while x increments(x is the counter or can be referred as a row)
- for(int y=0;y<ints[x].length;y++){ // now that we have the x counter we can address the index position [x] and iterate through it by defining its length first which is 5 on position index[0]
- System.out.print(ints[x][y]); // take out the values on that row by addressing ints[row position][column position]
- }
- System.out.println();// after the loop/taken out the values creates a new line then goes to the next row
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement