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 لعرض القيم الحقيقية أو المزيفة. هنا، القيمة "1" تساوي "2"، أي 1؛ لذا، العمل التالي هو-

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

العرض هو "صحيح"، لذا سنقوم بتحويل int إلى boolean.

دعونا الآن نرى المثال الكامل لفهم كيفية تحويل int إلى Boolean.

مثال

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

نتيجة الخرج

صحيح