What is operator

What is an Operator?

In Java, operators are symbols that perform various operations on variables, constants, and expressions. They allow you to manipulate data and perform calculations. Java provides a rich set of operators to use variables. Such as:

int a=30+20;

In the above code, ‘+’ operator is used. This operator can add two or multiple values. Or sometimes numerous variables.

Example:

int r= int a+ 21; // add a variable and a value 
int s= int a+ int r; // add two variables

Java supports a broad spectrum of operators, which can be classified into the following types:

1.Assignment Operators
2.Arithmetic Operators
3.Relational Operators
4.Logical Operators
5.Bitwise Operators
6.Unary Operators
7.Miscellaneous Operators

Operand:

When we talk about operators, we also need to know about operands. An operand indicates the values or variables used in different operations. Operands are the data on which the operations are performed. The operations are typically executed with the help of operators. Operands can be constants, variables, or expressions that evaluate to a specific value. They are essential components of any operation or computation performed in Java (and most other programming languages), and they help manipulate data to achieve desired results.

int operand1 = 5; // 'operand1' is an operand with the value 5
int operand2 = 10; // 'operand2' is another operand with the value 10
int sum = operand1 + operand2; // 'operand1 + operand2' is an expression with two operands and the '+' operator int operand1 = 5; // 'operand1' is an operand with the value 5
int operand2 = 10; // 'operand2' is another operand with the value 10

 

 

Visited 1 times, 1 visit(s) today

Comments are closed.

Close