Why is this an error?


#1

I’m just messing around with the boolean Not operator, trying a couple of different statements. Not sure why this is an error

<In what way does your code behave incorrectly? Include ALL error messages.>
Not.java:9: error: unexpected type
System.out.println( !(4 = 10) );
^
required: variable
found: value
1 error



public class Not {
	public static void main(String[] args) {

		System.out.println(!(false));
		System.out.println( !(5>=1) );
		
    System.out.println( ! (4 <= 10) );
    
    System.out.println( !(4 = 10) );
	}
}



#2

here:

System.out.println( !(4 = 10) );

a single equal sign means assign, so you assign a value of 10 to 4, how does that work? Maybe you want to check if 4 equals 10?


#3

Thanks for the quick reply. I knew it would be a simple answer.
Like you said, I was intending to check if they were equal. As soon as i saw reply, I realized I need == instead.


#4