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?

23rd Aug 2022, 2:29 PM
koalakodes
koalakodes - avatar
6 Answers
+ 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/
23rd Aug 2022, 2:46 PM
Jayakrishna 🇼🇳
+ 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)
23rd Aug 2022, 2:49 PM
koalakodes
koalakodes - avatar
+ 1
Usually && (in C and C-style languages). It would help if you specified which one (Python uses and)
23rd Aug 2022, 3:20 PM
Jonathan Shiell
23rd Aug 2022, 2:32 PM
koalakodes
koalakodes - avatar
0
The last bit of code at the bottom ^
23rd Aug 2022, 2:32 PM
koalakodes
koalakodes - avatar
0
Post update link here, if need.
23rd Aug 2022, 2:51 PM
Jayakrishna 🇼🇳