Expressions
Expressions are fundamental building blocks in Java programming. They represent a combination of variables, operators, and constants that produce a value. Understanding expressions is crucial for writing efficient and correct Java code. In this documentation, we will explore various types of expressions in Java along with suitable examples.
Types of Expressions
Arithmetic Expressions
Addition
Subtraction
Multiplication
Division
Modulus
Relational Expressions
Equal to
Not equal to
Greater than
Less than
Greater than or equal to
Less than or equal to
Logical Expressions
AND
OR
NOT
Assignment Expressions
Simple Assignment
Compound Assignment
Conditional (Ternary) Expression
Basic Ternary Operator
Nested Ternary Operators
Bitwise Expressions
AND (&)
OR (|)
XOR (^)
Bitwise NOT (~)
Left Shift (<<)
Right Shift (>>)
Unsigned Right Shift (>>>)
Instanceof Expression
Type Cast Expression
Method Call Expression
Array Access Expression
String Concatenation Expression
1. Arithmetic Expressions
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulus (%)
2. Relational Expressions
Equal to (==)
Not equal to (!=)
Greater than (>)
Less than (<)
Greater than or equal to (>=)
Less than or equal to (<=)
3. Logical Expressions
AND (&&)
OR (||)
NOT (!)
4. Assignment Expressions
Simple Assignment (=)
Compound Assignment (+=, -=, *=, /=, %=)
5. Conditional (Ternary) Expression
Basic Ternary Operator
Nested Ternary Operators
6. Bitwise Expressions
AND (&)
OR (|)
XOR (^)
Bitwise NOT (~)
Left Shift (<<)
Right Shift (>>)
Unsigned Right Shift (>>>)
7. instanceof Expression
8. Type Cast Expression
9. Method Call Expression
10. Array Access Expression
11. String Concatenation Expression
This documentation provides a comprehensive overview of various Java expressions with examples.
Last updated