M
M
Makaron30002021-04-15 13:55:46
Java
Makaron3000, 2021-04-15 13:55:46

How to output the third row in a two dimensional Java array?

Given a filled two-dimensional array, how to display only the third row? There is nothing on the internet about this issue.

public class April15 {

  public static void main(String[] args) {
    
    int[][]array = new int[][] {{2,5,2,4,3,5},
                              {1,5,7,4,2,6},
                              {3,6,11,95,45,87},
                              {4,6,3,6,7,2,7},
                              {66,33,67,87,23,13}};
      
  }

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-04-15
@Makaron3000

public class April15 {

  public static void main(String[] args) {
    
    int[][]array = new int[][] {{2,5,2,4,3,5},
                              {1,5,7,4,2,6},
                              {3,6,11,95,45,87},
                              {4,6,3,6,7,2,7},
                              {66,33,67,87,23,13}};
    
    for (int i = 2; i <3; i++) {
            for (int j = 0; j < 6; j++) {
                System.out.print(" " + array[i][j] + " "); 
            }
            System.out.println();
        }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question