This tutorial is explain about How many types of Java Operators explanation of arithmetic, logical, assigned and comparison operators with example of Java Programming.
Java Operators using a different types in Java:-
Arithmetic Operators:-
Additions(+):-
Example- int mValueA=10;
int mValueB=5;
int mSum= mValueA+ mValueB;
System.out.println("TotalValue=" +mSum);
Answer :- TotalValue=15
Substraction(-):-
Example- int mValueA=10;
int mValueB=5;
int mSub= mValueA-mValueB;
System.out.println("TotalValue=" +mSub);
Answer :- TotalValue=5
Most Read:-How to use if...else statement? Describe with example?
Multiplication(*):-
Example- int mValueA=10;
int mValueB=5;
int mMulti= mValueA*mValueB;
System.out.println("TotalValue=" +mMulti);
Answer :- TotalValue=50
Division(/):-
Example- int mValueA=10;
int mValueB=5;
int mDiv= mValueA/ mValueB;
System.out.println("TotalValue=" +mDiv);
Answer :- TotalValue=2
Modulus (%):-
Example- int mValueA=10;
int mValueB=5;
int mMod= mValueA %mValueB;
System.out.println("TotalValue=" +mMod);
Answer :- TotalValue=0
Increment (++)& Decrement (--):-
Example:- int mValueA=6;
int mValueB=mValueA++;
int mValueC=mValueB--;
System.out.println("Incremental Value="+mValueB);
System.out.println("Decremental Value="+mValueC);
Answer:- Incremental Value=7
Decremental Value=6
Assigned Oprators:- Assignment Operator is used to assign a value of variables for Examples:-
int x=5;
int x +=5;
Assigned Oprators is:- =,+=,-=,*=,/=,%=etc.
Comparison Oprators:- Comparison oprator is used to campare two values for example:-
If(a==b){
//If value is true then execute this code.
}
Comparison Oprators is:- ==,!=,<,>,<=,>= etc.
Logical Oprators:- this used to determine logic between variables or values.
Logical Oprators is :-
1. &&- this used to both value is true then the program execute. For example:-
if(a==b && b==c){
// Both conditions is true the execute this block.
System.out.println("Hello");
}
2. ||- this used to any one of conditions is true then the program execute. For example:-
if(a==b || b==c){
// Any one of conditions is true the execute this block.
System.out.println("Hello");
}
3. ! - this is use to return a reverse value if conditions is true then return false value For example:-
int a=4;
int b=8;
System.out.println(!(a>b));
//return true value
System.out.println(!(a<b));
// return false value
Download JDK :- JDK Setup download
0 Comments
Hello Friends, Please comment and share and do not write spam messages