Hey folks my IntelliJ is displaying everything as requested but I'm getting this error. I don't understand because IT IS DISPLAYING all strings.
package com.codegym.task.task07.task0727;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Changing functionality
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
while (true) {
String s = reader.readLine();
if (s.isEmpty()) break;
list.add(s);
}
ArrayList<String> newList = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
if (list.get(i).length() % 2 == 0) {
newList.add(list.get(i));
newList.add(list.get(i));
} else if (list.get(i).length() % 2 != 0) {
newList.add(list.get(i));
newList.add(list.get(i));
newList.add(list.get(i));
}
}
for (int i = 0; i < newList.size()-1; i++) {
if (newList.get(i).equals(newList.get(i + 1))) {
System.out.print(newList.get(i)+" ");
} else if (!newList.get(i).equals(newList.get(i + 1))) {
System.out.println(newList.get(i)+" ");
}
}
System.out.println(newList.get(newList.size()-1));
}
}