I'm having a terribly tough time with this simple code. My while conditions are always ignored and the print statement is executed. Please help.
package Checkpoints;
import java.util.Scanner;
public class Check05 {
public static void main (String[]args){
Scanner keyboard = new Scanner(System.in);
/**
* Write an input validation that asks the user to enter 'Y', 'y', 'N', or 'n'.
*/
String input, Y = null, N = null;
System.out.println("Please enter the letter 'Y' or 'N'.");
input = keyboard.nextLine();
while (!input.equalsIgnoreCase(Y) || !(input.equals(N)))
//|| input !=y || input !=N ||input !=n)
{
System.out.println("This isn't a valid entry. Please enter the letters Y or N" );
input = keyboard.nextLine();
}
}
}
YandNare null objects. Nothing is equal to anullobject.