❮ Previous Next ❯

Java Arithmetic Operators :

The operator taking two operands is called binary operators.
There are different binary operators are as follows :

The Arithmetic Operators:

The Java programming language provides operators that perform addition, subtraction, multiplication, and division. There's a good chance you'll recognize them by their counterparts in basic mathematics.
The only symbol that might look new to you is "%", which divides one operand by another and returns the remainder as its result.

  +   // addition operator (also used for String concatenation)
  -   // subtraction operator
  *   // multiplication operator
  /   // division operator
  %   //remainder operator
  class ArithmeticDemo
   {
     public static void main (String args[ ])
      {
      int x=15,y=4,z;
      z=x%y;
      System.out.println("z="+z);
     }
   }
Output

z=3

The + operator can also be used for concatenating (joining) two strings together, as shown in the following program:

  class ConcatDemo
   {
     public static void main(String args[ ])
     {
      String s1 = "Java";
      String s2 = " Race";
      String s3=s1+s2;
      System.out.println("s3="+s3);
     }
   }
Output:

s3=JavaRace

❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved