How to Use Arithmetic Operators in Java


Inthis example, we will learn how to use Arithmetic operators in Java.

Source Code

package com.beginner.examples;

public class ArithmeticOperatorsExample {

    public static void main(String[] args){
    	//Arithmetic operators
    	int a = 1 + 2;
		int b = 11 - 10;
		int c = 12 * 2;
		double d = 6 / 2;
		
		System.out.println("a = " + a);
		System.out.println("b = " + b);
		System.out.println("c = " + c);
		System.out.println("d = " + d);
	}
}

Output:

a = 3
b = 1
c = 24
d = 3.0
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments