BaşlayınÜcretsiz Başlayın

Bigger or smaller

Making decisions in code requires comparing values to determine which is larger, smaller, or if they're equal. Java provides comparison operators that evaluate to true or false, forming the foundation of program logic. Let's practice comparing numbers!

Bu egzersiz

Introduction to Java

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Save the result of checking if 5 is smaller than 7 to the boolean variable first.
  • Save the result of checking if 9 is greater than or equal to 2 to the variable second.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

class Comparisons {
    public static void main(String[] args) {
    	
        // Check if 5 is smaller than 7
        boolean first = 5 ____ 7;
        
        // Check if 9 is greater than or equal to 2
        boolean second = ____ ____ ____;
        
        System.out.println("5 is smaller than 7: " + first);
        System.out.println("9 is greater or equal to 2: " + second);
    }
}
Kodu Düzenle ve Çalıştır