Возникает NPE, хотя проверка != null есть, подскажите, что я делаю не так?(
package com.javarush.task.pro.task05.task0508;
import java.util.Scanner;
/*
Удаляем одинаковые строки
*/
public class Solution {
public static String[] strings;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
strings = new String[6];
for (int i = 0; i < 6; i++) {
strings[i] = sc.nextLine();}
for (int h = 0; h < 5; h++) {
boolean b = false;
for (int j = h + 1; j < 6; j++) {
if (strings[h].equals(strings[j]) && strings[j] != null && strings[h] != null) {
strings[j] = null;
b = true;}
if (b == true) {
strings[h]=null;
}
}
}
for (int i = 0; i < strings.length; i++) {
System.out.print(strings[i] + ", ");
}
}
}