Arithmetic Operators

Start course
2h 12m

In this course, we'll learn the fundamentals of Java. 

Learning Objectives

  • Variables
  • Data Types
  • Type Conversion & Type Casting
  • Operators
  • Operator Precedence 
  • Expressions, Statements and Block

Intended Audience

  • Anyone looking to get Oracle Java Certification
  • Those who want to learn the Java Programming language from scratch
  • Java developers who want to increase their knowledge
  • Beginners with no previous coding experience in Java programming
  • Those who want to learn tips and tricks in Oracle Certified Associate – Java SE 8 Programmer certification exams


  • No prior knowledge is required about the Java programming language.
  • Basic computer knowledge

Hi there. In this section, we will talk about Operators. Operators are special symbols that perform specific operations, such as arithmetic, logical, etc. The value that the operator operates on is called the operand. For example, in the expression x + 4, the x and 4 are operands and plus(+) is an operator. In this section, first we'll learn Arithmetic, Assignments, and Unary Operators. Then we will learn Equality, Relational, and Conditional Operators. Then we'll learn Operator Precedence. Let's start with arithmetic operators. The Java programming language provides operators that perform addition, subtraction, multiplication, division, and remainder. These are basic mathematical operations that you know. Plus(+) is the additive operator. It adds two operands. Minus(-) is the subtraction operator.

It subtracts right operand from the left. Asterisk(*) is the multiplication operator. It multiplies two operands. Forward slash(/) is the division operator. It divides left operand by the right one. The type of division result is float by default. The percentage(%) is the remainder operator. This symbol might look new to you. It divides one operand by another and returns the remainder as its result. Okay, let's try to understand Java operators with examples. In exercise project, right click on the source folder and select new, class. Specify package name as 'operator' and class name as 'ArithmeticOperator'. And select the checkbox to add the main method. Let's declare three variables with double type. First, number1 and assign 8.4. Second, number2 and assign 4.2. And lastly, result with the initial value 0.0. First, assign 'number1 + number2' to the variable 'result'. Let's show the result value by using the print method. 

We'll run the program after all operations. Let's copy the code and change the operator with the subtraction operator, and change the operator in the print method. Okay, let's make changes for multiplication. Let's make changes for the division. Finally, let's make changes again for the remainder operator. That's all. Let's run the code. As you can see in the console, number1 + number2 = 12.6, number1 - number2 = 4.2, number1 * number2 = 35.28, number1 / number2 = 2.0, number1 % number2 = 0.0, so the remainder is 0. Also, the plus(+) operator can be used for concatenating, joining two strings together. So, let's create two strings. 

The name of the first string can be 'firstString' and its value can be "This is". Now let's create the second string. The name of this can be 'secondString' and its value can be "a concatenated string". Now let's create the third string. The name of this can be 'thirdString' and its value will be 'firstString + secondString'. Let's print the third string to the console. Now let's run the code. As you can see, the result is, 'This is a concatenated string'. Okay, let's take a short break here. See you in the next video.


About the Author
Learning Paths

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics