Advertisement
KahnClifford

Output row value on Array

Dec 21st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public class MyClass {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. 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)
  6. 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)
  7. 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]
  8. System.out.print(ints[x][y]); // take out the values on that row by addressing ints[row position][column position]
  9. }
  10. System.out.println();// after the loop/taken out the values creates a new line then goes to the next row
  11. }
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement