Advertisement
bal_gennady

Array06

Dec 19th, 2016
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. import static pro.java.util.Print.*;
  2.  
  3. public class Array06 {
  4.     public static void main(String[] args) {
  5.         // Примеры многомерных массиво Java
  6.         println("Шаг 1");
  7.         int[][] multiplicationTable = new int[10][];
  8.         println("multiplicationTable = " + multiplicationTable + '\n');
  9.  
  10.         println("Шаг 2");
  11.         for (int i = 0; i < 10; i++)
  12.         println("multiplicationTable[" + i + "] = " + multiplicationTable[i]);
  13.  
  14.         println("\nШаг 3");
  15.         for (int i = 0; i < 10; i++) {
  16.             multiplicationTable[i] = new int[10]; // создаем 10 массивов int
  17.             println("multiplicationTable[" + i + "] = " + multiplicationTable[i]);
  18.         }
  19.  
  20.         println("\nСодержимое массива после создания");
  21.         for (int i = 0; i < 10; ++i) {
  22.             for (int j = 0; j < 10; ++j) {
  23.                 print(" " + multiplicationTable[i][j]);
  24.             }
  25.             println();
  26.         }
  27.  
  28.         println("\nСодержимое массива после присвоения значений");
  29.         for (int i = 0; i < 10; ++i) {
  30.             for (int j = 0; j < 10; ++j) {
  31.                 multiplicationTable[i][j] = i * j;
  32.                 print(" " + multiplicationTable[i][j]);
  33.             }
  34.             println();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement