Operator¶
Operators in Java¶
Operator in Java is a symbol that is used to perform operations.
There are many types of operators in Java which are given below:
Here is a brief introduction to Java operators:
-
Arithmetic Operators:
Perform basic mathematical operations like addition (+
), subtraction (-
), multiplication (*
), division (/
), and modulus (%
). -
Relational Operators:
Compare two values, resulting in a boolean (true
orfalse
). Examples include==
,!=
,>
,<
,>=
, and<=
. -
Logical Operators:
Used to combine multiple boolean expressions. Common operators are&&
(AND),||
(OR), and!
(NOT). -
Bitwise Operators:
Operate on bits of integers. Includes&
(AND),|
(OR),^
(XOR),~
(NOT),<<
(left shift),>>
(right shift). -
Assignment Operators:
Assign values to variables. The basic operator is=
, and combined operators include+=
,-=
,*=
,/=
, etc. -
Unary Operators:
Operate on a single operand. Includes increment (++
), decrement (--
), positive (+
), and negative (-
). -
Ternary Operator:
A shorthand forif-else
condition. Syntax:condition ? expr1 : expr2
. -
Instanceof Operator:
Tests whether an object is an instance of a specific class or subclass. Syntax:obj instanceof ClassName
.
Short Video Lecture¶
(Video here)
VisualCodeChat Tutoring (Exercise: Integer Division and Remainder)¶
Interact and Learn with VisualCodeChat!
After-class Exercises¶
(Exercises here)