0
Multiple Requirements in one if statement
I want to add two requirements for an if statement to work. For example if(x > 10; y < 5){ System.out.println(“blah blah”); } What is the correct way (if there is) to add two requirements in one if statement?
6 ответов
+ 4
learn about logical operators to make compound multiple conditions.
&& logical and operator.
if ((Condition 1) && ( condition 2))
Ex:
if( x > 10 && y < 5 ) {
..
}
Similarly :
|| => or operator......
https://www.geeksforgeeks.org/java-logical-operators-with-examples/amp/
+ 1
Ohhhhh, each condition has to be in separate (). I tried the && but where I messed up is I put the conditions in the same ( ) ex; if(x > 5 && y < 10).
Thank you for the speedy reply && help (See what I did there? Lol)
+ 1
Usually && (in C and C-style languages). It would help if you specified which one (Python uses and)
0
The last bit of code at the bottom ^
0
Post update link here, if need.