In the previous article, we have discussed about Java Program on Subtraction Operator
In this article we will see the use of Multiplication operator in Java.
Java Program on Multiplication Operator
Multiplication operator is a binary operator and it is used to multiply two numbers. Multiplication operator is represented by the *
symbol.
Syntax: operand * operand
Example:
Let’s understand it more clearly.
Suppose we have 2 variables a and b.
a=2
b=13
Then we can use multiplication operator like this.
result=a*b; // here 2 variable operands are multiplied
(or)
result = 15 * a; // here one constant operand i.e. 15 and variable operand i.e. ‘a
‘ multiplied
Program:
import java.io.*; class Main { public static void main(String[] args) { //Declaring variables int number1 = 100; int number2 = 2; //multiplying two numbers by using multiplication operator int result = number1*number2; //print results System.out.println("By performing multiplication operation: " + result); } }
Output: By performing multiplication operation: 200
Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.
Related Java Programs: