Error in my simple JAVA code


Somebody plzz help me out here.Im new in JAVA....

it shows the error below: error: bad operand type int for unary operator '!'
System.out.println( (!5<=1) );
1 error

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

		System.out.println( (!5<=1) );


This is an easy fix fortunately. If you're going to use the NOT operator on a comparison, the comparison has to be within quotes. With that in mind, your code will look like:

System.out.println( !(5<=1) );

Other than that, everything looks fine! If you have any other issues, don't be afraid to make a post about it.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.