Home java How to fill the two-dimensional array in java

How to fill the two-dimensional array in java

Author

Date

Category

I can not understand how to fill the two-dimensional array of numbers from 1 to 8 with a dimension of 8 to 8, except to fill it manually. But it is not very effective. How to make?


Answer 1, Authority 100%

Public Class Main {
Public Static Void Main (String [] Args) {
   int [] [] arr = new int [8] [8];
   For (int i = 0; i & lt; arr.length; i ++) {
     for (int j = 0; j & lt; arr [i] .length; j ++) {
       Arr [i] [j] = j + 1;
     }
   }
   For (int [] Anarr: ARR) {
     for (int ananarr: anarr) {
       System.Out.print (Ananarr + ");
     }
     System.Out.printLN ();
   }
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions