Java Learn
Java Learn
What is operators?
● ARITHMETIC OPERATOR
● ASSIGNMENT OPERATOR
● RELATIONAL OPERATOR
● LOGICAL OPERATOR
● INCREMENT/DECREMENT OPERATOR
● CONDITIONAL OPERATOR
MISCELLANEOUS
ARITHMETIC OPERATOR
‘+’ Operator:
ADDITION
+
CONCAT
ACTIVITY:
1.Write a java program to perform addition of two numbers.
2.Write a java program to concat a number and String.
3.Write a java program to concat a floating number and String.
4.Write a java program to concat a integer and character.
5.Write a java program to concat a character and String.
6.Write a java program to concat a integer,character,boolean and
String data.
ASSIGNMENT OPERATOR:
1. +=
2. -=
3. *=
4. /=
Operator Example Equivalent to
= a=b; a=b;
+= a+=b; a=a+b;
- -= a-=b; a=a-b;
Operator Example Equivalent to
a*=b; a=a*b;
*=
/= a/=b; a=a/b;
%= a%=b; a=a%b;
RELATIONAL OPERATORS:
&&(Logical AND)
If all the expression returns true then this operator will
return true
||(Logical OR)
If any of one of the expression return true then this operator
will return true
! (Logical NOT)
It the result is true then it will return false and vice versa
AND TABLE :
Increment Operator:
● Pre-Increment Operator
● Post-Increment Operator
Decrement Operator:
● Pre-Decrement Operator
● Post-Decrement Operator
INCREMENT OPERATOR
SYNTAX:
TRUE
FALSE
● Conditional Operator will check the condition,if
condition is true operand 2 will gets executed,if
condition is false operand 3 ill gets executed.
Note :
● The return value of conditional operator is always
boolean.
● The return value of operand 1 is based on operand
2 and operand 3.
EXAMPLE:
Class Demo
{
public static void main(String[] args)
{
int a = 10;
int b =20;
int c = (a>b) ? a : b; //Conditional Operator
System.out.println(c); // 20
}
}
TRACE THE PROGRAMS: (INCREMENT OPERATOR)
s.o.p(res);