Arithmetic Operators Example : Arithmetic Operators « Language Basics « Java






Arithmetic Operators Example

 



public class Main {

  public static void main(String[] args) {
    int i = 5 + 2;
    int j = i - 1;
    int k = j * 2;
    double l = k / 6;

    System.out.println("i = " + i);
    System.out.println("j = " + j);
    System.out.println("k = " + k);
    System.out.println("l = " + l);
  }
}
/*
i = 7
j = 6
k = 12
l = 2.0
*/

   
  








Related examples in the same category

1.Arithmatic Assignment Operators
2.Increment and Decrement Operators