Operators and Expressions
Operators​
Java supports various operators for arithmetic, comparison, logical operations, etc.
Arithmetic Operators​
+
(addition)-
(subtraction)*
(multiplication)/
(division)%
(modulus)
Example:
int sum = 10 + 5; // 15
int difference = 10 - 5; // 5
Comparison Operators​
==
(equal to)!=
(not equal to)>
(greater than)<
(less than)>=
(greater than or equal to)<=
(less than or equal to)
Example:
boolean isEqual = (10 == 10); // true
boolean isGreater = (10 > 5); // true
Logical Operators​
&&
(logical AND)||
(logical OR)!
(logical NOT)
Example:
boolean result = (true && false); // false
boolean orResult = (true || false); // true
Conclusion​
Understanding Java syntax and structure is crucial for writing effective and efficient Java programs. By mastering these basics, you can begin to build more complex and powerful applications.