Whats wrong with my code didnt able to recognised in boolean precedence


#1



Replace this line with your code.


#2

Please can you provide us with a bit more context to the problem?

Ideally: The code, instruction in question and any error messages you received.


#3

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

	boolean riddle = ( !(1 < 8)&& (5 > 2 || 3 < 5));
	System.out.println(riddle);

}

}

this is my code but answer is coming false still it showing theres something wrong im unable to get ...


#4

Almost! Did you use each Boolean operator no more than one time?
this error is being displayed to me


#5

Okay I see.

You're code is technically right, because it evaluates to false and you used all the operators like it asked for. But the lesson logic which tests to see if you have done the right thing is counting your solution as a not pass because for one reason or another it believes you didn't accomplish the task.

Compare:

  boolean riddle = /**/( 1 < 8 /**/ (5 > 2 /**/ 3 < 5));    //----> Default code
//boolean riddle = (  !( 1 < 8) &&  (5 > 2  ||  3 < 5));      ----> Your code

Where those comments are in the first line of the above code is more or less where the lesson is expecting you to make changes. So try limiting your alterations in those areas and see if the exercise will let you pass.


#6

sry but i didnt get what u said plz explain in precise ...


#7

i got it thanx a lot ...


#8

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