What is an Operator?
Java offers a comprehensive collection of operators for working with variables. Examples include:
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. Operands are the data on which the operations are performed. The operations are typically executed with the help of operators. 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