Can anyone help me here? I've spent a ridiculous amount of time on this question, looked in the help section, with no success. What could be the problem?
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
BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
ArrayList<Integer> main = new ArrayList<Integer>();
ArrayList<Integer> byTwo = new ArrayList<Integer>();
ArrayList<Integer> byThree= new ArrayList<Integer>();
ArrayList<Integer> others = new ArrayList<Integer>();
//add input to main arraylist
for (int i = 0; i < 20; i++){
main.add(Integer.parseInt(br.readLine()));
}
//add items from main list to supplementary lists
for (int i = 0; i < main.size(); i++){
int x = main.get(i);
if(x % 3 == 0){
byThree.add(x);
if (x % 3 == 0){
byTwo.add(x);
}
} else if (x % 2 == 0){
byTwo.add(x);
} else{
others.add(x);
}
}
//System.out.println("byThree: ");
printList(byThree);
//System.out.println("byTwo: ");
printList(byTwo);
//System.out.println("others: ");
printList(others);
}
public static void printList(List<Integer> list) {
//write your code here
for (Integer i : list){
System.out.println(i);
}
}
}