Sample Code
public class Arithmetic_Operator{
public static void main(String[] args) {
int x =10;
int y =5;
int z;
z = x+y; // + addition
System.out.println(z);
z = x-y; // - subtraction
System.out.println(z);
z =x*y; // * Multiplication
System.out.println(z);
z= x/y; // / Division
System.out.println(z);
z= x%y; // % Modulus
System.out.println(z);
}
}
Example Code
public class Arithmetic_OperatorsExample {
public static void main(String[] args) {
System.out.println("10+5= " + (10 + 5));
System.out.println("10-5= " + (10 - 5));
System.out.println("10*5= " + (10 * 5));
System.out.println("10/5= " + (10 / 5));
System.out.println("10%5= " + (10 % 5));
}
}