Answer the question
In order to leave comments, you need to log in
Why can't java code be executed in sublime text?
The builder says:
{
"shell_cmd": "javac \"$file\" && java \"$file_base_name\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"path": "C:\\Program Files\\Java\\jdk1.8.0_211\\bin",
"shell":true
}
public static void main(String[] args) throws Exception {
ArrayList<Integer> list0 = new ArrayList<>();
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
ArrayList<Integer> list3 = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 20; i++) {
list0.add(Integer.parseInt(reader.readLine()));
}
for (int i = 0; i < list0.size(); i++) {
if (list0.get(i) % 3 == 0) list1.add(list0.get(i));
if (list0.get(i) % 2 == 0) list2.add(list0.get(i));
if ((list0.get(i) % 3 != 0) & (list0.get(i) % 2 != 0)) list3.add(list0.get(i));
}
printList(list1);
printList(list2);
printList(list3);
}
public static void printList(ArrayList<Integer> list) {
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question