Create a class for 2D array learning.

public class two_d_arrays{

    
}

Create a method to initialize a 2D array with arbitrary values

public class two_d_arrays{
    public static int[][] numbers = new int[4][4];

    public static void initialize(){
        for (int i=0; i<4; i++){
            for (int j =0; j<4; j++){
                numbers[i][j] = i+j+29;
            }
        }


        for(int i =0; i < numbers.length; i++)
        {
            for (int j=0; j<numbers[i].length; j++){ 
                System.out.print(numbers[i][j] + " ");
            }
            System.out.println();
        }

        



    }
    
    


    public static void main(String[] args){
        two_d_arrays.initialize();
    }
}


two_d_arrays.main(null);
29 30 31 32 
30 31 32 33 
31 32 33 34 
32 33 34 35 

Create a method to reverse the 2D array and print out the values

public class two_d_arrays{
    public static int[][] numbers = new int[4][4];

    public static int[][] initialize(){
        for (int i=0; i<4; i++){
            for (int j =0; j<4; j++){
                numbers[i][j] = i+j+29;
            }
        }


        for(int i =0; i < numbers.length; i++)
        {
            for (int j=0; j<numbers[i].length; j++){ 
                System.out.print(numbers[i][j] + " ");
            }
            System.out.println();
        }
      


        return(numbers);
    }



    public static void reverse(){
        int[][] reverse_arr = new int[4][4];
        for(int i =0; i < numbers.length; i++)
        {
                for (int j=0; j<numbers[i].length; j++){
                reverse_arr[numbers.length - 1 - i][numbers[i].length - 1 - j] = numbers[i][j];
            }
        }

        

        for(int i =0; i < reverse_arr.length; i++)
        {
            for (int j=0; j<reverse_arr[i].length; j++){ 
                System.out.print(reverse_arr[i][j] + " ");
               // System.out.println(numbers[i][j]);
            }
            System.out.println();
        }


        
    }   
    


    public static void main(String[] args){
       System.out.println("Original: ");
        two_d_arrays.initialize();
        System.out.println();
        System.out.println("reversed: ");
        two_d_arrays.reverse();
    }
}






two_d_arrays.main(null);
Original: 
29 30 31 32 
30 31 32 33 
31 32 33 34 
32 33 34 35 

reversed: 
35 34 33 32 
34 33 32 31 
33 32 31 30 
32 31 30 29 

Create a method that asks for the input of a position and it returns the corresponding value

import java.util.Scanner;

public class two_d_arrays{
    public static int[][] numbers = new int[4][4];

    public static int[][] initialize(){
        for (int i=0; i<4; i++){
            for (int j =0; j<4; j++){
                numbers[i][j] = i+j+29;
            }
        }


        for(int i =0; i < numbers.length; i++)
        {
            for (int j=0; j<numbers[i].length; j++){ 
                System.out.print(numbers[i][j] + " ");
            }
            System.out.println();
        }
      


        return(numbers);
    }

    public static void position(){
        Scanner i_obj = new Scanner(System.in);  // Create a Scanner object     
        String i_s = i_obj.nextLine();  // Read user input
        int i = Integer.parseInt(i_s);

        Scanner j_obj = new Scanner(System.in);  // Create a Scanner object     
        String j_s = j_obj.nextLine();  // Read user input
        int j = Integer.parseInt(j_s);


        System.out.print(numbers[i][j]);
        
       
    }



   
    public static void main(String[] args){
       System.out.println("Original: ");
        two_d_arrays.initialize();
        
        System.out.println();
        System.out.println("used scanner object to input row and column: ");
        System.out.println("i = 2 ");
        System.out.println("j = 3 ");
        two_d_arrays.position();
    }
}






two_d_arrays.main(null);
Original: 
29 30 31 32 
30 31 32 33 
31 32 33 34 
32 33 34 35 

used scanner object to input row and column: 
i = 2 
j = 3 
34

Create a method that multiplies each value in a row and then adds all the products together

public class two_d_arrays{
    public static int[][] numbers = new int[4][4];

    public static int[][] initialize(){
        for (int i=0; i<4; i++){
            for (int j =0; j<4; j++){
                numbers[i][j] = i+j+29;
            }
        }


        for(int i =0; i < numbers.length; i++)
        {
            for (int j=0; j<numbers[i].length; j++){ 
                System.out.print(numbers[i][j] + " ");
            }
            System.out.println();
        }
      


        return(numbers);
    }

    public static int product(){
        int final_counter = 0;
        for (int i=0; i<4; i++){
            int row_product = 1;
            for (int j=0; j<4; j++){
                row_product = row_product * numbers[i][j];

            }

            final_counter = final_counter + row_product;
        }
        System.out.println(final_counter);
        return final_counter;

    }
    
    


    public static void main(String[] args){
        two_d_arrays.initialize();
        System.out.println();
        two_d_arrays.product();
    }
}


two_d_arrays.main(null);
29 30 31 32 
30 31 32 33 
31 32 33 34 
32 33 34 35 

4214784

Create a new object to test out each method in the main function

public class two_d_arrays{
    public static int[][] numbers = new int[4][4];

    public static int[][] initialize(){
        for (int i=0; i<4; i++){
            for (int j =0; j<4; j++){
                numbers[i][j] = i+j+29;
            }
        }


        for(int i =0; i < numbers.length; i++)
        {
            for (int j=0; j<numbers[i].length; j++){ 
                System.out.print(numbers[i][j] + " ");
            }
            System.out.println();
        }
      


        return(numbers);
    }



    public static void reverse(){
        int[][] reverse_arr = new int[4][4];
        for(int i =0; i < numbers.length; i++)
        {
                for (int j=0; j<numbers[i].length; j++){
                reverse_arr[numbers.length - 1 - i][numbers[i].length - 1 - j] = numbers[i][j];
            }
        }

        

        for(int i =0; i < reverse_arr.length; i++)
        {
            for (int j=0; j<reverse_arr[i].length; j++){ 
                System.out.print(reverse_arr[i][j] + " ");
               // System.out.println(numbers[i][j]);
            }
            System.out.println();
        }


        
    }   
    



    
    public static void position(){
        Scanner i_obj = new Scanner(System.in);  // Create a Scanner object     
        String i_s = i_obj.nextLine();  // Read user input
        int i = Integer.parseInt(i_s);

        Scanner j_obj = new Scanner(System.in);  // Create a Scanner object     
        String j_s = j_obj.nextLine();  // Read user input
        int j = Integer.parseInt(j_s);


        System.out.print(numbers[i][j]);
        
       
    }


    
    public static int product(){
        int final_counter = 0;
        for (int i=0; i<4; i++){
            int row_product = 1;
            for (int j=0; j<4; j++){
                row_product = row_product * numbers[i][j];

            }

            final_counter = final_counter + row_product;
        }
        System.out.println(final_counter);
        return final_counter;

    }

    
    public static void main(String[] args){
        System.out.println("Original: ");
         two_d_arrays.initialize();
         
         System.out.println();
         System.out.println("reversed: ");
         two_d_arrays.reverse();
 
 
         System.out.println("Original: ");
         two_d_arrays.initialize();
         System.out.println();
         System.out.println("used scanner object to input row and column: ");
         System.out.println("i = 2 ");
         System.out.println("j = 3 ");
         two_d_arrays.position();

         two_d_arrays.product();
     }



}






two_d_arrays.main(null);
Original: 
29 30 31 32 
30 31 32 33 
31 32 33 34 
32 33 34 35 

reversed: 
35 34 33 32 
34 33 32 31 
33 32 31 30 
32 31 30 29 
Original: 
29 30 31 32 
30 31 32 33 
31 32 33 34 
32 33 34 35 

used scanner object to input row and column: 
i = 2 
j = 3 
344214784

Extra work:

Notes/additonal research - notes for it are linked on the ticket.