Choose Language

Monday, 26 November 2012

5.1 Operators in Java | Arithmetic Operators

There are operators used for performing Mathematical and Logical operations in Java. They are Arithmetic, Assignment, Bitwise, Compound, Increment/decrement, Relational, Ternary, Logical Operator.

 class arithmetic  
      void operator()  
           int a=20,b=10;  //This is the Data type of Integer
           System.out.println("Add "+(a+b));  // plus operator
           System.out.println("Diff "+(a-b));  // minus operator
           System.out.println("Mul "+(a*b));   // multiplication operator
           System.out.println("Div "+(a/b));   // Division Operator
           System.out.println("Moduluo "+(a%b));  // Modulos will leave the remainder on dividing two numbers
 class operator  
      public static void main(String ar[])  
           arithmetic a = new arithmetic();   // a is the object created using the new operator representing the class Arithmetic 
           a.operator();  // a is the object of the class arithmetic 
            // calling operator method present in the class arithmetic through the object a

The above code illustrates the arithmetic operation comprising operators [+,-,*,/,%]


Post a Comment

Trending Now. . .

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by RANDJITH | Bloggerized by Randjith - Subscribe to Learn in Tamil | coupon codes