*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes short circuit logical operands Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "short circuit logical operands" Watch "short circuit logical operands" New topic
Author

short circuit logical operands

Libania Paes
Greenhorn

Joined: Aug 02, 2002
Posts: 14
Hi!
I couldn�t find anywhere in the book Java 2 Sun Certified Programmer from Osborne something about short circuit operands.
What are they?

Thanks!!!
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
&& and || .
Probably not everyone calls them "short-circuit" operators.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Libania Paes
Greenhorn

Joined: Aug 02, 2002
Posts: 14
Thanks, Ron!
But there�s a question before mine that says:

Please explain about & and |. Can some one run through the following example.
public class ShortCkt {
public static void main(String args[]) {
int i = 0;
boolean t = true;
boolean f = false, b;
b = (t & ((i++) == 0));
b = (f & ((i+=2) > 0));
System.out.println(i);
}
}

& and | are Bitwise operators only, right??
Thanks again!
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
& and | are both bit-wise operators and boolean operators. However, when they are boolean operators, both operands are always evaluated first.
^ is also both a bit-wise operator and a boolean operator.
[ August 16, 2002: Message edited by: Ron Newman ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: short circuit logical operands
 
Similar Threads
Why bitwise operators can be used in boolean expressions?
Q. from Jxam
Question about & and |
Jxam question 30
Simple If statement syntax