Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, I am learning java right now and I don\'t know I can I solve this problem //

ID: 3871375 • Letter: H

Question

Hi, I am learning java right now and I don't know I can I solve this problem

  //2. write code that initializes a 2x3 array of Strings called coordinates to contain the (x,y) coordinates of a grid, starting with (0,0) at the top left.

--------------------------------------------------

this is my answer

String[][] coordinates = new String [2][3];

          

           for (int i = 0; i < 2; i++)

      for (int j = 0; j < 3; j++ ) {

         coordinates[i][j] = "0" + "0";

  

     

      }

            

Explanation / Answer

Please find my code.

public class Test {

   public static void main(String[] args) {

      

       String[][] coordinates = new String [2][3];

       for (int i = 0; i < 2; i++) {

           for (int j = 0; j < 3; j++ ) {

              

               coordinates[i][j] = "("+i +","+ j+")";

           }

       }

      

       for (int i = 0; i < 2; i++) {

           for (int j = 0; j < 3; j++ ) {

              

               System.out.print(coordinates[i][j]+" ");

              

           }

           System.out.println();

       }

   }

}

/*

Sample run:

(0,0) (0,1) (0,2)

(1,0) (1,1) (1,2)

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote