Java division operator: In the previous article, we have discussed about Java Program on Multiplication Operator
In this article we will see the use of division operator in Java.
Java Program on Division Operator
Division operator is a binary operator and it is used to divide two numbers. Division operator is represented by the /
symbol. After division it returns the quotient value.
Syntax: operand / operand
Example:
Let’s understand it more clearly.
Suppose we have 2 variables a and b.
a=20
b=5
Then we can use division operator like this.
result = a / b; // here 2 variable operands are divided.
result = 20/5=4
(or)
result = 15 / b; // here one constant operand i.e. 15 and variable operand i.e. ‘b
‘ divided.
result= 15/5=3
Program:
import java.io.*; class Main { public static void main(String[] args) { //Declaring variables int number1 = 39; int number2 = 2; //dividing two numbers by using division operator int result = number1/number2; //print results System.out.println("By performing division operation: " + result); } }
Output: By performing division operation: 19
If you are new to Java and want to learn the java coding skills too fast. Try practicing the core java programs with the help of the Java basic programs list available.
Related Java Programs: