Last active
June 11, 2016 21:35
-
-
Save josinSbazin/e07736c4537677515c7f9bf6f6131502 to your computer and use it in GitHub Desktop.
level09.lesson11.home08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson11.home08; | |
import java.util.ArrayList; | |
import java.util.Random; | |
/* Список из массивов чисел | |
Создать список, элементами которого будут массивы чисел. Добавить в список пять объектов–массивов | |
длиной 5, 2, 4, 7, 0 соответственно. Заполнить массивы любыми данными и вывести их на экран. | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) | |
{ | |
ArrayList<int[]> list = createList(); | |
printList(list); | |
int[] a = {1,3,4,5}; | |
} | |
public static ArrayList<int[]> createList() | |
{ | |
final Random rand = new Random(); | |
ArrayList<int[]> ar = new ArrayList<int[]>();//напишите тут ваш код | |
ar.add(new int[5]); | |
ar.add(new int[2]); | |
ar.add(new int[4]); | |
ar.add(new int[7]); | |
ar.add(new int[0]); | |
for (int i = 0; i < ar.size(); i++) { | |
for (int j = 0; j < 8; j++) { | |
try | |
{ | |
ar.get(i)[j] = rand.nextInt(100); | |
} catch (IndexOutOfBoundsException e) { | |
continue; | |
} | |
} | |
} | |
return ar; | |
} | |
public static void printList(ArrayList<int[]> list) | |
{ | |
for (int[] array: list ) | |
{ | |
for (int x: array) | |
{ | |
System.out.println(x); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment