## Logical Operators Vs Auto increment & decrements

Types of Java Operators, Operator Precedence, Arithmetic Operators, Comparison or Relational Operators, Logical Operator and Bitwise Operators etc.
AyubHussain
Posts: 142
Joined: Fri Nov 23, 2018 2:48 am

### Logical Operators Vs Auto increment & decrements

What is Auto-increment and Auto-decrements Operators and what is Logical Operators?

dsusmitha
Posts: 62
Joined: Fri Nov 23, 2018 2:51 am

### Re: Logical Operators Vs Auto increment & decrements

Auto-increment and Auto-decrement java Operators in java are: ++ and —

num ++ is equivalent to num=num+1;
num –- is equivalent to num=num-1;

Example of Auto-increment and Auto-decrement Operators

package package_Java;

public class AutoOperator_Java {
public static void main(String args[]) {
int num1 = 100;
int num2 = 200;
num1++;
num2--;
System.out.println("num1++ is: " + num1);
System.out.println("num2-- is: " + num2);
}
}

Logical Operators :
Logical operators in java are: &&,||, !

1.Logical Operators are used with binary variables.
2.They are mainly used in conditional statements and loops for evaluating a condition.
3.b1 && b2 will return true if both b1 and b2 are true else it would return false.
4.b1 || b2 will return false if both b1 or b2 are false else it would return true.
5.!b1 would return the opposite of b1, that means it would be true if b1 is false and it would return false if b1 is true.

Example of Logical Operators

package package_Java;
public class LogicalOperator_Java {
public static void main(String args[]) {
boolean b1 = true;
boolean b2 = false;

System.out.println("b1 && b2: " + (b1 && b2));
System.out.println("b1 || b2: " + (b1 || b2));
System.out.println("!(b1 && b2): " + !(b1 && b2));
}
}

satyanarayanareddy
Posts: 24
Joined: Thu Jan 03, 2019 3:54 am

### Re: Logical Operators Vs Auto increment & decrements

Increment operator (++):
========================
Increment operator is an operator which is used to increase the value of a variable by 1,on which it is applied.
Again these increment operators are two types:
=>Pre increment (++x) = If an Increment operator is used in front of an operand, then it is called as Pre Increment operator.
=>Post increment (x++) = If an Increment operator is used after an operand, then is called Post Increment operator.

Decrement Operator (- -):
=========================
The Decrement operator is an operator which is used to decrease the value of the variable by 1,on which it is applied.
Like increment operators, decrement operators are also two types,
=>Pre decrement (- -x) = If an decrement operator is used in front of an operand, then it is called Pre decrement operator.
=>Post decrement (x- -) = If an decrement operator is used after an operand, then it is called Post decrement operator.

satyanarayanareddy
Posts: 24
Joined: Thu Jan 03, 2019 3:54 am

### Re: Logical Operators Vs Auto increment & decrements

What are the Limitations of these increment and decrement operators?