Operator
|
Description
|
+
|
Addition
|
-
|
Subtraction
|
*
|
Multiplication
|
/
|
Division
|
%
|
Modulus/ Remainder
|
Program 1 to demonstrate Arithmetic operators
/** JavaMadeSoEasy.com */
public class ArithmeticOperatorTest {
public static void main(String[] args) {
int x=4;
int y=2;
int result=x+y;
System.out.println("+ "+ result); //6
result=x-y;
System.out.println("- "+ result); //2
result=x*y;
System.out.println("* "+ result); //8
result=x/y;
System.out.println("/ "+ result); //2
result=x%y;
System.out.println("% "+ result); //0
}
}
/*OUTPUT
+ 6
- 2
* 8
/ 2
% 0
*/
|
Labels:
Core Java
core java Basics