---
title: "Cannot convert from int to Boolean using java"  
description: "Cannot convert from int to Boolean using java"  
author: "Kate Smith"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1662/cannot-convert-from-int-to-boolean-using-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Cannot convert from int to Boolean using java

```
public static void main(String[] args)

{
    int [] newArray= new int [4];
    int [] array = {4,5,6,7};
    oddEven(array);

    newArray[0] = array[0]+array[1]+array[2]+array[3];
    newArray[1] = array[0]*array[1]*array[2]*array[3];

}

public static void oddEven(int [] oddEven)
{

    for (int i=0; i<oddEven.length; i++)
    {
        if (oddEven[i] % 2)      //  Cannot convert from int to boolean
    }
}
```

Ignore what I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to manage here. I'm only curious why it doesn't [accept](https://yourviews.mindstick.com/view/81278/we-have-to-accept-that-roger-federer-is-the-richest-one) "if" statement in this [for loop](https://www.mindstick.com/forum/12568/android-for-loop-not-working-in-main-thread). As I stated it says "cannot [convert from int](https://www.mindstick.com/forum/33392/how-to-convert-from-int-to-string-in-java) to [boolean](https://www.mindstick.com/forum/160332/how-does-the-boolean-function-work)". Why do you think it says so?

## Replies

### Reply by Hank Greenberg

That expression should be realizes an boolean in side the if, otherwise compilation error.

**Try to this code: -**\

```
if (oddEven[i] % 2 ==0)  {
 //Code Here
}
```


---

Original Source: https://www.mindstick.com/forum/1662/cannot-convert-from-int-to-boolean-using-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
