wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Short-Circuit Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Short-Circuit Problem" Watch "Short-Circuit Problem" New topic
Author

Short-Circuit Problem

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344




Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
||(short circuit OR) don't bother to check the second OR if the first one is true while (|) bitwize OR does.


~Sanjeev Singh<br />SCJP 1.5
annapurna madala
Greenhorn

Joined: Oct 30, 2006
Posts: 6
As you said thats the short-circuit problem
In the first case, ++z>5 evaluates to true, so the ++z>6 will not be evaluated(because '||' is a short-circuit operator)
where as in the second case, even when the first operand evaluates to true ++z>6 will be executed giving the output as 8
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Short-Circuit Problem