Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Arithmetic Operators

class Main {
  public static void main(String[] args) {
        // declare variables
    int a = 12, b = 5;
    // addition operator
    System.out.println("a + b = " + (a + b));
    // subtraction operator
    System.out.println("a - b = " + (a - b));

    // multiplication operator
    System.out.println("a * b = " + (a * b));

    // division operator
    System.out.println("a / b = " + (a / b));

    // modulo operator
    System.out.println("a % b = " + (a % b));
  }
}
 
PREVIOUS NEXT
Tagged: #Java #Arithmetic #Operators
ADD COMMENT
Topic
Name
1+4 =