Задачи на ArrayList в Java. Часть 6
Дан двумерный ArrayList:
List<List<Integer>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(1, 2, 3)),
new ArrayList<>(List.of(4, 5, 6)),
new ArrayList<>(List.of(7, 8, 9))
));
Даны два числа:
int i = 1;
int j = 2;
Получите элемент, расположенный на позиции, заданной числами i и j.
Дан двумерный ArrayList:
List<List<Integer>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(1, 2, 3)),
new ArrayList<>(List.of(4, 5, 6))
));
Добавьте новую строку [7, 8, 9] в конец матрицы.
Дан двумерный ArrayList:
List<List<String>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of("a", "b", "c")),
new ArrayList<>(List.of("d", "e", "f")),
new ArrayList<>(List.of("g", "h", "i"))
));
Замените элемент в последней строке и среднем столбце на "x".
Дан двумерный ArrayList:
List<List<Integer>> matrix = List.of(
List.of(1, 2),
List.of(3, 4),
List.of(5, 6)
);
Создайте изменяемый ArrayList и добавьте в него все элементы матрицы в виде одномерного ArrayList.
Дан двумерный ArrayList:
List<List<Integer>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(10, 20)),
new ArrayList<>(List.of(30, 40))
));
Увеличьте каждый элемент матрицы в 2 раза.
Дан двумерный ArrayList:
List<List<Integer>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(1, 0, 1)),
new ArrayList<>(List.of(0, 1, 0)),
new ArrayList<>(List.of(1, 0, 1))
));
Найдите сумму всех элементов матрицы.
Дан двумерный ArrayList:
List<List<Integer>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(5, 3, 8)),
new ArrayList<>(List.of(2, 9, 1)),
new ArrayList<>(List.of(7, 4, 6))
));
Найдите максимальный элемент в матрице.
Дан двумерный ArrayList:
List<List<Integer>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(1, 2, 3)),
new ArrayList<>(List.of(4, 5, 6))
));
Добавьте новый столбец [7, 8] в конец каждой строки.
Дан двумерный ArrayList:
List<List<Boolean>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of(true, false)),
new ArrayList<>(List.of(false, true)),
new ArrayList<>(List.of(true, true))
));
Инвертируйте все логические значения в матрице (true → false, false → true).
Дан двумерный ArrayList:
List<List<String>> matrix = new ArrayList<>(List.of(
new ArrayList<>(List.of("cat", "dog")),
new ArrayList<>(List.of("bird", "fish"))
));
Объедините все элементы матрицы в одну строку через запятую.