Any ideas?
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 {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<>();
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
ArrayList<Integer> list3 = new ArrayList<>();
for (int i = 0; i < 20; i++) {
int numbers = Integer.parseInt(reader.readLine());
list.add(numbers);
}
for(Integer x : list) {
if(x % 3 == 0) {
list1.add(x);
} else
if(x % 2 == 0) {
list2.add(x);
} else
if(x % 2 == 0 && x % 3 == 0) {
list1.add(x);
list2.add(x);
} else
list3.add(x);
}
printList(list1);
printList(list2);
printList(list3);
}
public static void printList (List < Integer > list) {
//write your code here
for (Integer x : list) {
System.out.println(x);
}
}
}