Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Division Operators in Java
The division operator in Java includes the Division, Modulus, and the Divide And Assignment operator. Let us work with them one by one −
Divison Operator
The division operator divides left-hand operand by right-hand operand.
Modulus Operator
The modulus operator divides left-hand operand by right-hand operand and returns remainder.
Divide And Assignment Operator
This operator divides left operand with the right operand and assign the result to left operand.
Let us now see an example −
Example
public class Demo {
public static void main( String args[] ) {
int a = 10;
int b = 20;
int c = 25;
System.out.println("b / a = " + (b / a) );
System.out.println("b % a = " + (b % a) );
c /= a ;
System.out.println("c /= a = " + c );
}
}
Output
b / a = 2 b % a = 0 c /= a = 2
Advertisements
