Why we are using "&" And "!b" In the printing line what's it used for? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we are using "&" And "!b" In the printing line what's it used for?

public class Main { public static void main(String[] args) { int a=100; boolean b=false; System.out.println(++a>100&!b); } }

1st May 2021, 4:15 PM
kreddyt
kreddyt - avatar
4 Answers
+ 1
Karthik Reddy Thotamgari & Operator behaves same like as && operator but it evaluate all conditions even they are false ! operator is called unary operator that takes a Boolean value as its operand so here ++a = 101 And !b = !false = true So finally (101 > 100 & true) = true
1st May 2021, 4:27 PM
A͢J
A͢J - avatar
1st May 2021, 5:54 PM
Atul [Inactive]
+ 1
About !b
1st May 2021, 5:54 PM
Atul [Inactive]
0
Atul ik abt that but the logic here is bit confusing ... Yea it's clear now
1st May 2021, 5:56 PM
kreddyt
kreddyt - avatar