---
title: "what is short circuit operator in java"  
description: "what is short circuit operator in java"  
author: "Anonymous User"  
published: 2014-10-01  
updated: 2014-10-03  
canonical: https://www.mindstick.com/forum/2293/what-is-short-circuit-operator-in-java  
category: "java"  
tags: ["java", "oops"]  
reading_time: 1 minute  

---

# what is short circuit operator in java

example of [short circuit](https://www.mindstick.com/forum/162070/what-is-short-circuit-in-software-development) [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server)

## Replies

### Reply by Anonymous User

The OR operator results in true when one operand is true, no matter what the second operand is.The AND operator results in false when one operand is false, no matter what the second operand is.If you use the || and &&, Java will not evaluate the right-hand operand when the outcome can be determined by the left operand alone.The following code shows how you can use short-[circuit](https://www.mindstick.com/forum/162028/what-is-circuit-breakers) logical operator to ensure that a division operation will be valid before evaluating it:

```
class Program{    static void Main(string[] args)    {            int x = 0;            int y = 0;            for(int i=0;i<10;i++)            {                if (x++ < 7 || y++ < 5) ;            }            System.out.println(x);            System.out.println(y);    }}
```


---

Original Source: https://www.mindstick.com/forum/2293/what-is-short-circuit-operator-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
