Arithmetic operators in Java Programming

Arithmetic operators in Java Programming

Previous Home Next

 

Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra.


Java provides eight Arithmetic operators. They are for addition, subtraction, multiplication,
 division, modulo (or remainder), increment (or add 1), decrement (or subtract 1),and negation.
The binary operator + is overloaded in the sense that the operation performed is determined by the type of the operands.
When one of the operands is a String object,
the other operand is implicitly converted to its string representation and string concatenation is performed.
 
int x = 20;
 
int y = 10, z ;
z=x+y;


 

public ArithmeticOperators()
{
int x = 20 y = 10, z ;
z=x+y;
System.out.println("+ operator resulted in " +z);
public static void main(String arg[])

{
new Arithmeticoperators();
}
}

Previous Home Next