I'm currently writing a program that requires me to check several char values using a while statement and I keep getting the error "operator || cannot be applied to char, char". My code works fine with a single value but as soon as I add || or && I get this error. Any help would be greatly appreciated.

String primeColour ;
	primeColour = "none" ;

	String secColour ;
	secColour = "none" ;

	char FColour ;
	FColour = 'N' ;

	char SColour;
	SColour = 'P';

	System.out.print ("\n\nEnter primary colour for car:		") ;
	Colour = user.next().charAt(0);


	while (FColour != ('B' || 'L' || 'W' || 'R' || 'Y' || 'G'))  
	{
	            System.out.print("\nAvaible colors codes are B, L, W, R, Y and G");
	            System.out.print("\nReenter choice for primary colour:		");
	            FColour = user.next().charAt(0); 
                 }

i would create a method called isInSet and you iterate through the characters and check, you can't do a character check the way you are wanting to unless you add them to a list or an array of some sort

You have to compare each one explicitly.

boolean invalidColor = (FColour != 'B' && FColour != 'L' && FColour != 'W' && FColour != 'R' && FColour != 'Y' && FColour != 'G');

Thanks a lot guys, I have 3 assignments I need to finish but I had this same problem with each. So I can final get up to date, again thanks

This question has already been answered. Start a new discussion instead.