+ 3
Someone plz xplain to me how OR operator works in conditiona loops
what is the reasoning behind it
3 Answers
+ 4
The OR and AND operation is used specific more than 1 if statement. This syntax is used to make the code shorter, gab writing if statement after if statement:
public class Main{
    public static void main(String[]arcs){
        int x = 0;
        int y = 0;
      //OR operation
      if(x <=0 || y <=0){
       //this is saying if x OR y are less or equal to 0
       // the code if statement is true
     }
 
     //AND operation
     if(x <=0 && y <= 0){
        /*this is when you initialized that both statements need to be true for the overall out come to be true*/
}
if the OR and AND operations weren't involve then the code would have looked like his:
Or statement without AND operation:
if(x <=0){
    if(y <= Y){
       //the code if both statement are true
     }
    // the code if the first statement if true
    }
   }
}
+ 3
got it
+ 1
Like it does in english language! ;)
Conditional loop check if a statement is true, if you write a statement with an OR operator, if a part of the statement containing one or many OR operator is true, the whole statement is true, so the loop continues...
Hope I made it understandable...



