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

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology
Call to: 9439202111  |  9658317757  |  0674-2361252

Comment