If statement Java


#1

My code below:

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

		if !('a'=='A') {

			System.out.println("Access granted.");

		}
		
	}
}

the Boolean expression gives true as required by exercise but when run the console give error
If.java:4: error: ‘(’ expected
if !(‘a’==‘A’) {
^
If.java:4: error: ‘)’ expected
if !(‘a’==‘A’) {
^
2 errors
Please advise me, thanks


#2

why not simply make ! part of the comparison? != means not equal, that really simplify matters for you


#3

Try putting the ! inside the parenthesis. Something like this ( ! 2==2); The other thing I was thinking but it is kind of a shot in the dark. Is is possible they system does that the a and the A and not equal to one another because of the difference in case.

Good luck and Happy Coding,
Joel


#4

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