Padd Solutions

Converted by Falcon Hive

TwoDArray

9:09 AM 0 comments

public class TwoDArray
{
    public static void main (String[] args)
    {
        int[][] table = {
                          {4, 5, 4, 3},
                          {7, 3, 5, 7},
                          {4, 3, 5, 2},
                          {4, 1, 2, 0}
                        };
                       
        //System.out.println (table[3][2]);
        //table [0][0] = table[0][0] * 10;
       
        int row = table.length;
        int cols = table[0].length;
       
        for (int r = 0; r < table.length; r++)
        {
            for (int c = 0; c < table[r].length; c++)
            {
                System.out.print (table[r][c] + " ");
            }
            System.out.println ();
        }
       
        System.out.println ();
       
        for (int r = 0; r < table.length; r++)
        {
            for (int c = 0; c < table[r].length; c++)
            {
                System.out.print (table[r][c] * 10 + " ");
            }
            System.out.println ();
        }
               
        System.out.println ();
       
        //prints first result
        for (int[] rows : table)
        {
            for (int col : rows)
            {
                System.out.print (col);
            }
            System.out.println ();
        }
    }
                                }

(0) Comments

Post a Comment