Can't get it
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> Main = new ArrayList<>();
ArrayList<Integer> By3 = new ArrayList<>();
ArrayList<Integer> By2 = new ArrayList<>();
ArrayList<Integer> ByBoth = new ArrayList<>();
for (int i = 0; i < 20; i++)
{
Main.add(Integer.parseInt(reader.readLine()));
}
for (int i = 0; i < Main.size(); i++)
{
Main.get(i);
if (Main.get(i) % 3 == 0 || Main.get(i) % 2 == 0 && Main.get(i) % 3 == 0) {
By3.add(Main.get(i));
}
else
{
ByBoth.add(i);
}
}
for (int i = 0; i < Main.size(); i++)
{
Main.get(i);
if (Main.get(i) % 2 == 0 || Main.get(i) % 3 == 0 && Main.get(i) % 2 == 0) {
By2.add(Main.get(i));
}
else
{
ByBoth.add(i);
}
}
System.out.println("Divisible by 3 \n");
printList(By2);
System.out.println("Divisible by 2 \n");
printList(By3);
System.out.println("Remaining \n");
printList(ByBoth);
}
public static void printList(List<Integer> list) {
for (int j: list
) {
System.out.println(j);
}
}
}