The code I've written reads 6 strings from the console, finds duplicated ones among them, substitutes them with null and produces the expected output. Why does it still fail validation (in particular, does not meet the 2nd requirement)?
package en.codegym.task.pro.task05.task0508;
import java.util.Scanner;
public class Solution {
public static String[] strings;
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
strings = new String[6];
for (int x = 0; x < strings.length; x++) {
strings[x] = console.nextLine();
}
for (int y = 0; y < strings.length; y++) {
for (int z = y + 1; z < strings.length; z++){
if (strings[z] != null && strings[z].equals(strings[y])) {
strings[z] = null;
strings[y] = null;
}
}
}
//write your code here
for (int i = 0; i < strings.length; i++) {
System.out.print(strings[i] + ", ");
}
}
}