Debugging flow with c#
This is an example of short-circuit OR operator.

import java.io.*;
// javac operator_shortcircuit_c.java
public class operator_shortcircuit_c
{
public static void main(String args[])throws IOException
{

InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
////////////////
try{
System.out.println("---If statement---");
double x = 0;
double y = 0;
String str = "";
System.out.print("Please enter age: ");
str = br.readLine();
x = Double.parseDouble(str);
System.out.print("Please enter hieght in feet: ");
str = br.readLine();
y = Double.parseDouble(str);
//short circuit ||, if 1st is true only go for the second
//if 1st is not true don't bother to check on the second
int n1 = (int)x;
int n2 = (int)y;
System.out.println("----x >= 10 | y >= 5---");
if ( x >= 10 | y >= 5)
{
if (x >= 10){System.out.println("\tx => 10 " + true );}
if (y >= 5){System.out.println("\ty => 5 " + true );}
System.out.println("n1/n2= " + n1/n2);
}
System.out.println("----( x >= 10 || y >= 5)---");
//short circuit AND, if 1st is true only go for the second
//if 1st is not true don't bother to check on the second
if ( x >= 10 || y >= 5)
{
if (x >= 10){System.out.println("\tx => 10 " + true );}
if (y >= 5){System.out.println("\ty => 5 " + true );}
System.out.println("n1/n2= " + n1/n2);
}
}//try
catch(NumberFormatException e) { System.out.println("data was blank");}
///
System.out.println();
}//end of main
}//end of class
/*
boolean b;
b = 3 > 2 | 5 > 7; // b is true since 1st operand is true
b = 2 > 3 || 5 < 7; // b is now ture since second operand is true
The conditional-OR operator (||) performs a logical-OR of its bool operands, but only evaluates its second operand if necessary.
*/

Case :1
  • Here 1st operand and 2nd both in OR (|) operator, is true

Case :2
  • Here only the 1st operand is true

Case : 3
  • Here 1st operand is false but 2nd is true.