Hi there,
I noticed this issue of the java compiler and cant understand why .. ?
So if there is an empty element in the array, it does not goes to the if statement??
{"", "", "", "sam","i","am."}
array[i].equals(empty) || array[i].equals(empty1)
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
s = s.toLowerCase();
String[] array = s.split(" ");
List<String> list1 = new ArrayList<>();
String empty = "";
String empty1 = " ";
for (int i = 0; i < array.length; i++) {
if (array[i].equals(empty) || array[i].equals(empty1)) {
continue;
}
else {
list1.add(array[i]);
}
}
for (String element:list1) {
System.out.println(element);
}