Java boolean operators precedence


#1
boolean riddle = /**/( 1 < 8 /**/ (5 > 2 /**/ 3 < 5));

the ans must be false and have to use boolean operator onlyonce


#2

What have you tried so far?
Do you know of three boolean operators that you can use?


#3

I do not understand how,


#4

The exercise is asking you to find the /**/ on line 4 and replace them with either !, && or ||.


#5

I already tried this but it is quite complicated for me......and to my regret I'll leave this exercise to further :pensive:


#6

Oh I get it, I was having the same problem but what you are supposed to do is use !, && or ||. to replace the /**/s to get false. remember that ! is the not operator, && is the and operator || is the or operator. If you don't want to figure it out, The answer is

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
..

..

.
.
..

..
.
.
!( 1 < 8 && (5 > 2 || 3 < 5))


#7

conditionals and control flow/ lesson 5

pls help with this

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

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

}

}


#8

Did your riddle print out true or false?
You must put the !, && || in the right places to have it print out false.


#9

this is my code below;

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

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

}

}


#10

You've done all the work to work out a value for your riddle variable, you should just print that instead.


#11

kindly help with the code

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

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

}

}


#12

That line should be:

    System.out.println(riddle);

In the line before that you are working our a value for riddle, now you just print it.


#14

Thanks for the help! I did not see that you had to remove the "//" My program threw 6 errors so I started counting the // and there were 6. Very confusing when you are new to this.