Answers for "java print 2d array row and column"

1

java print 2d array as table

static void debugV2(Object... obj) {
        System.out.println(Arrays.deepToString(obj)
                .replace("],", "n").replace(",", "t")
                .replaceAll("[\[\]]", " "));
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj).replace("], ", "]n"));
    }
Posted by: Guest on December-12-2020
0

java print 2d array row and column

public class TwoDimensionalArrays
{
public static void main (String args[])
{
    final int size1 = 2, size2 = 4, size3 = 5;
    int [][] numbers = {{20,25,34,19,33}, {11,17,15,45,26}, {27,22,9,41,13}};        
    int row = 0, col = 0;

        for(row = 0; row <= size1; row++); //loops through rows
        {
            for(col = 0; col <= size2; col++); //loops through columns
            {
                System.out.println(numbers[row][col]);
            }
        System.out.print("n"); //takes a new line before each new print
        }
    }
 }
Posted by: Guest on November-22-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language