What's wrong here? when I checked with the correct solution it is basically the same code. did I miss something?
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> nm = new ArrayList<Integer>();
for (int i = 0; i < 20; i++) {
int k = Integer.parseInt(reader.readLine());
nm.add(k);
}
ArrayList<Integer> non = new ArrayList<Integer>();
ArrayList<Integer> divisibleByThree = new ArrayList<Integer>();
ArrayList<Integer> divisibleByTwo = new ArrayList<Integer>();
for (int h = 0; h < nm.size(); h++) {
Integer s = nm.get(h);
if ((s%2 == 0) || (s%3 == 0)) {
if (s%2 == 0) {
divisibleByTwo.add(s);
}
if (s%3 == 0) {
divisibleByThree.add(s);
}
else {
non.add(s);
}
}
}
printList(divisibleByThree);
printList (divisibleByTwo);
printList (non);
}
public static void printList(List<Integer> list) {
for (Integer g : list) {
System.out.println(g);
}
}
}