I worked for a long time on this and was able to figure it out this morning, but it failed both criteria for validation? I am able to set duplicates to null, beyond what the input is, e.g., "hello" "hello" "hello". I am really stumped as to why the first validation requirement is not being met?
package en.codegym.task.pro.task05.task0508;
import java.util.Scanner;
/*
Remove duplicate strings
*/
public class Solution {
public static String[] strings;
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
String[] strings = new String[6];
for(int i = 0; i < strings.length; i++){
strings[i] = scn.nextLine();
}
int tmp = 0;
for(int q = 0; q < strings.length; q++){
if(strings[q] == null)
continue;
for(int p = (q + 1); p < strings.length; p++)
if(strings[q].equals(strings[p])){
tmp = q;
strings[p] = null;
}
strings[tmp] = null;
}//write your code here
for (int i = 0; i < strings.length; i++) {
System.out.print(strings[i] + ", ");
}
}
}