I don't understand, I looked on the Internet, for similar solutions in the community, and used ChatGPT as a last resort, and I still can't figure out how to solve the problem in the last subpoint
package pl.codegym.task.task07.task0713;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Granie w Javarellę
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> glowna = new ArrayList<>();
ArrayList<Integer> podzielnaPrzez3 = new ArrayList<>();
ArrayList<Integer> podzielnaPrzez2 = new ArrayList<>();
ArrayList<Integer> reszta = new ArrayList<>();
for (int i = 0; i < 20; i++) {
int l = Integer.parseInt(reader.readLine());
glowna.add(l);
}
for (int i = 0; i < glowna.size(); i++) {
if (glowna.get(i) % 3 == 0) {
podzielnaPrzez3.add(glowna.get(i));
}
if (glowna.get(i) % 2 == 0) {
podzielnaPrzez2.add(glowna.get(i));
}
if (glowna.get(i) % 3 != 0 && glowna.get(i)%2 != 0){
reszta.add(glowna.get(i));
}
printLista(podzielnaPrzez3);
printLista(podzielnaPrzez2);
printLista(reszta);
}
}
public static void printLista(List<Integer> lista) {
for(Integer idk : lista){
System.out.println(idk);
}
}
}