English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java 프로그램, int를 지정된 변환 값의布尔 값으로 변환합니다

要将int转换为boolean,让我们首先获取以下int。

int one = 1;
int two = 1;
int three = 0;

我们嵌套了if-else 문으로 true 또는 false 값을 표시합니다. 여기서 값“ 1”与“ 2”相同,即1;因此,以下工作-

else if (one.equals(two)) {
   System.out.println(true);
}

上面的显示为“ true”,因此我们将int转换为boolean。

지금让我们看完整的示例,以了解如何将int转换为Boolean。

예제

public class Demo {
   public static void main(String[] args) {
      int one = 1;
      int two = 1;
      int three = 0;
      //int to Boolean-
      if (one == two) {
         System.out.println(true);
      } else if (one == three) {
         System.out.println(false);
      }
   }
}

출력 결과