Error in my simple JAVA code


#1

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

it shows the error below:
Not.java:5: 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(!false);
		System.out.println( (!5<=1) );
		
	}
}


#2

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.


#3

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