Advertisement
jaVer404

level09.lesson11.home08

Apr 26th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. package com.javarush.test.level09.lesson11.home08;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.ArrayList;
  7.  
  8. /* Список из массивов чисел
  9. Создать список, элементами которого будут массивы чисел.
  10. Добавить в список пять объектов–массивов длиной 5, 2, 4, 7, 0 соответственно.
  11. Заполнить массивы любыми данными и вывести их на экран.
  12. */
  13.  
  14. public class Solution
  15. {
  16.     public static void main(String[] args) throws IOException
  17.     {
  18.         ArrayList<int[]> list = createList();
  19.         printList(list);
  20.     }
  21.  
  22.     public static ArrayList<int[]> createList() throws IOException
  23.     {
  24.         //Написать тут ваш код
  25.         ArrayList<int[]> myArrays = new ArrayList<int[]>();
  26.         int[] array5 = new int[5];
  27.         int[] array2 = new int[2];
  28.         int[] array4 = new int[4];
  29.         int[] array7 = new int[7];
  30.         int[] array0 = new int[0];
  31.         myArrays.add(array5);
  32.         myArrays.add(array2);
  33.         myArrays.add(array4);
  34.         myArrays.add(array7);
  35.         myArrays.add(array0);
  36.         for (int[]some_array : myArrays) {
  37.             for (int i = 0; i < some_array.length; i++) {
  38.                 some_array[i] = i;
  39.             }
  40.         }
  41.         return myArrays;
  42.     }
  43.  
  44.     public static void printList(ArrayList<int[]> list)
  45.     {
  46.         for (int[] array: list )
  47.         {
  48.             for (int x: array)
  49.             {
  50.                 System.out.println(x);
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement