Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

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

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext