If you have any query feel free to chat us!
Happy Coding! Happy Learning!
In Java, operators are special symbols that perform specific operations on one or more operands (variables, constants, or literals). Java supports a wide range of operators that allow you to perform arithmetic, relational, logical, bitwise, and assignment operations, among others. Here are the main types of operators in Java:
+
: Addition-
: Subtraction*
: Multiplication/
: Division%
: Modulus (remainder)==
: Equal to!=
: Not equal to>
: Greater than<
: Less than>=
: Greater than or equal to<=
: Less than or equal to&&
: Logical AND||
: Logical OR!
: Logical NOT&
: Bitwise AND|
: Bitwise OR^
: Bitwise XOR~
: Bitwise NOT (complement)<<
: Left shift>>
: Right shift (with sign extension)>>>
: Right shift (zero-fill)=
: Simple assignment+=
: Add and assign-=
: Subtract and assign*=
: Multiply and assign/=
: Divide and assign%=
: Modulus and assign&=
: Bitwise AND and assign|=
: Bitwise OR and assign^=
: Bitwise XOR and assign<<=
: Left shift and assign>>=
: Right shift and assign (with sign extension)>>>=
: Right shift and assign (zero-fill)++
: Increment by 1--
: Decrement by 1++num
) or post-increment (num++
).? :
: Conditional expression (short for if-else)The usage of these operators depends on the context and the data types involved in the operations. Understanding how to use these operators effectively is crucial for writing efficient and accurate Java programs.
Comments: 0