|
| ||||||||||
| Tags: java operators, operators in java, short circuit, short circuit operators |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Don't know about short-circuit operators of java
I totally confused about one unknown type of operators of java. In java book I have read somewhere about the 'short-circuit operators'. But didn't get more details about it. I don't anything about the short-circuit operators of java. According to my knowledge this type of operators are not available in the C and C++. If you know about the short-circuit operators in java, then please let me aware about that. |
|
#2
| ||||
| ||||
| Re: Don't know about short-circuit operators of java
In java language 'Boolean OR' and 'Boolean AND' are referred as short-circuit operators. These short-circuit operators are not available in other programming languages. These operators are of secondary versions. If you use the | | and && operators forms, rather than | and & forms of these operators, java will not bother to evaluate the right-hand operand alone. As we can see from the preceding table of operators, that the OR operator results in true only when A is true. |
|
#3
| |||
| |||
| Re: Don't know about short-circuit operators of java
Hi, The && and || operators in java normally known as short-circuit operators. If you use the || operator instead of the | operator and if 'A' is true then java will not evaluate 'B'. If value A or B is true then' A|B' is must be true. The same applies to the operation A&&B and if 'A' is false then java will not evaluate B and the result is false. The java comprises other logical operators also rather than short-circuit operators such as ==, | , & , ^, != , !, ?: , ||. |
|
#4
| ||||
| ||||
| Re: Don't know about short-circuit operators of java
Hi friend, Most of the java user don't about the shot-circuit operators of the java. The Boolean 'AND' as well as the Boolean 'OR' are called as short-circuit operators of java. In below program I have used the 'AND' short-circuit operator, see below: Quote:
|
|
#5
| ||||
| ||||
| Re: Don't know about short-circuit operators of java
|| and && operators are called as short-circuit operators of java. These short-circuit operators of java are very essential when the right hand operand of expression depends upon the left operand one being true or false in order to function properly. Suppose the below fragment code shows how we can take advantage of short-circuit logical evaluation to be sure that a division operation will be valid before evaluating it's value: Quote:
|
|
#6
| ||||
| ||||
| Re: Don't know about short-circuit operators of java
Hi friend, To evaluate expression "X2 && Y2", you first need to evaluate X. Suppose If 'X' value is false then stop and the whole expression will be false. Otherwise, evaluate 'Y' value then AND the these two values. This idea is basically called as short-circuit evaluation. Programmers frequently make use of this feature. For example, suppose two methods that return false or true values are combined in a Boolean expression: Quote:
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Don't know about short-circuit operators of java" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Short circuit on Asus Crosshair V motherboards due to EK-FB water-block | S.I.K | Motherboard Processor & RAM | 2 | 23-04-2012 11:23 AM |
| Can power supply short circuit raise some problem | Banjiji | Hardware Peripherals | 4 | 27-11-2009 04:45 PM |
| Bitwise logical operators in Java | beelow | Software Development | 3 | 20-11-2009 12:25 PM |
| Motherboard short circuit | djbbenn | Motherboard Processor & RAM | 4 | 21-05-2009 12:58 PM |
| will short circuit in audio output damage the motherboard? | riceboy | Motherboard Processor & RAM | 2 | 18-12-2008 12:02 PM |