About 4,930,000 results
Open links in new tab
  1. Vertical 5x5 2D Array in Java - Stack Overflow

    You're printing values before you populate them. First fill your array, then print it. You assign matrix[i][j] but print matrix[j][i] (i and j are flipped). Suggest you create separate method for …

  2. Print a 2D Array or Matrix in Java - GeeksforGeeks

    Mar 24, 2025 · In this article we cover different methods to print 2D Array. When we print each element of the 2D array we have to iterate each element so the minimum time complexity is O …

  3. Print a 2D Array or Matrix in Java - Online Tutorials Library

    Learn how to print a 2D array or matrix in Java with examples and step-by-step instructions.

  4. java - Printing out a 2D array in matrix format - Stack Overflow

    public void printMatrix(int[][] matrix) { for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < matrix[row].length; col++) { System.out.printf("%4d", matrix[row][col]); } …

  5. Program to print the Diagonals of a Matrix - GeeksforGeeks

    Oct 9, 2023 · Define a function print_diagonals that takes a 2D list (matrix) as input. Get the length of the matrix and store it in the variable n. Use a list comprehension to create a list of …

  6. How to create a 5x5 matrix with increasing numbers in java?

    May 23, 2020 · int c = 1; for(int i=0;i<Example.length;i++){ for(int k=0;k<Example.length;k++) if (k <= i) { System.out.print(c++ +" "); } else { System.out.print(0 +" "); } System.out.println(); } Or if …

  7. java - How can I print a 5x5 room grid using a 2D array ... - Stack ...

    Aug 6, 2020 · I need to create a 5X5 grid of rooms that has 5 rows and 5 columns with a 2d Array. I have the square rooms created in a toString but every time I try to print it with a nested for …

  8. arrays - Print matrix in Java - Stack Overflow

    Jan 26, 2016 · Just print commas and brackets around your loop and after the number: System.out.print("["); for (int k = 0; k < Matrix[0].length; k++) { . System.out.print(Matrix[j][k] + " …

  9. java - How to fix output to be on separate lines to create a 5x5 matrix ...

    Jul 31, 2019 · Using a nested for loop (which is a for loop inside a for loop), you can print the data out in a way that looks more "grid-like." A possible solution to your issue could look something …

  10. How to print Two-Dimensional Array like table - Stack Overflow

    More efficient and easy way to print the 2D array in a formatted way: Try this: public static void print(int[][] puzzle) { for (int[] row : puzzle) { for (int elem : row) { System.out.printf("%4d", …

  11. Some results have been removed
Refresh