Operators in Java
Operators in Java are symbols that represent operations to be performed on variables or values. They are used to manipulate data and perform calculations. Java supports a variety of operators, categorized into different types based on their functionality. Here are the main types of operators in Java:
1. Arithmetic Operators: These operators perform basic mathematical operations.
· + (Addition)
· - (Subtraction)
· * (Multiplication)
· / (Division)
· % (Modulus, calculates the remainder of a division)
2. Assignment Operators: These operators are used to assign values to variables.
· = (Assignment)
· += (Addition assignment)
· -= (Subtraction assignment)
· *= (Multiplication assignment)
· /= (Division assignment)
· %= (Modulus assignment)
3. Increment and Decrement Operators: These operators are used to increase or decrease the value of a variable by one.
· ++ (Increment by one)
· -- (Decrement by one)
4. Comparison Operators: These operators are used to compare values and return boolean results (true or false).
· == (Equal to)
· != (Not equal to)
· > (Greater than)
· < (Less than)
· >= (Greater than or equal to)
· <= (Less than or equal to)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5. Logical Operators: These operators are used to perform logical operations.
· && (Logical AND)
· || (Logical OR)
· ! (Logical NOT)
These are some of the fundamental operators being used in Java to writing Java code, as they allow you to perform a wide range of operations on variables and values.
IMPORTANT: For operators precedence CLICK HERE
Comments
Post a Comment