I am wondering if this question can be solved in Java (I'm new to the language). This is the code:
class Condition {
// you can change in the main
public static void main(String[] args) {
int x = 0;
if (x == x) {
System.out.println("Ok");
} else {
System.out.println("Not ok");
}
}
}
I received the following question in my lab:
How can you print "Not ok" without modifying the condition?
Edit
How can you skip the first case (i.e. make the x == x
condition false) without modifying the condition itself?
System.out.println("Gotcha!");
instead of the comment? :).cross()
and the other is.dot()
and there is no confusion. Also the fact that "override the == operator and always return false" can't happen seems pro java