Maybe im not undestend task. Help me please.
package com.codegym.task.task07.task0713;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Playing Javarella
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
//1. Declare and immediately initialize 4 ArrayList<Integer> variables.
// The first list will be the main one. The other lists will be supplementary.
List<Integer> listAll = new ArrayList<>();
List<Integer> listDivisibleBy3 = new ArrayList<>();
List<Integer> listDivisibleBy2 = new ArrayList<>();
List<Integer> listRest = new ArrayList<>();
// 2. Read 20 numbers from the keyboard and add them to the main list.
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 20; i++) {
int x = Integer.parseInt(reader.readLine());
listAll.add(x);
}
//3. Add to the first supplementary list all numbers in the main list that are divisible by 3.
//4. Add to the second supplementary list all numbers in the main list that are divisible by 2.
//5. Add to the third supplementary list all the remaining numbers from the main list.
for (int i = 0; i < listAll.size(); i++) {
if (listAll.get(i) % 3 == 0) {
listDivisibleBy3.add(listAll.get(i));
}
}
for (int i = 0; i < listAll.size(); i++) {
if (listAll.get(i) % 2 == 0) {
listDivisibleBy2.add(listAll.get(i));
}
}
for (int i = 0; i < listAll.size(); i++) {
if ((listAll.get(i) % 3 != 0) && listAll.get(i) % 2 != 0) {
listRest.add(listAll.get(i));
}
}
printList(listDivisibleBy3);
printList(listDivisibleBy2);
printList(listRest);
}
public static void printList(List<Integer> list) {
//write your code here
for (Integer e : list) {
System.out.println(e);
}
}
}
/*
1
2
3
4
5
6
7
8
9
0
11
2
22
33
44
55
66
77
88
99
*/