false || false
→ false
false || true
→ true
true || false
→ true
true || true
→ true
The evaluation is guaranteed to proceed in strict left to right order, and if any boolean is true, it does not evaluate any expressions to the right of that. This lets you write code like this:
// if s is null, Java won't bother to test the length of s if ( s == null || s.length() == 0 ) { out.println( "empty string" ); }
| You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | |
| http://mindprod.com/jgloss/mccarthyoroperator.html | J:\mindprod\jgloss\mccarthyoroperator.html | |
![]() | ||
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.191.103] | |
| Feedback | You are visitor number 11. | |