Tsallaka zuwa abun ciki
Justice Tech School

Operators

Arithmetic, comparison, logical, assignment and bitwise operators. Integer division drops the fraction.

Example
public class Main {
  public static void main(String[] args) {
    int a = 7, b = 2;
    System.out.println(a / b + " " + a % b + " " + (double) a / b);
    System.out.println((a > b && b > 0) + " " + (a++) + " " + (++a));
  }
}

Result

3 1 3.5
true 7 9

Exercise

Remainder.

7  2

Quiz Test

What is 7 / 2 in ints?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.