Java uses logical operators AND(&&),OR(||),NOT(!).These operator yield 1 or 0 depending upon the outcome of different expressions.The different types of logical operators with their format are:
Precedence of logical operators is NOT(!) then AND(&&) and then OR(!!).
The AND operator results in true if both the expressions are true.
e.g 4>2 && 6>3 : result in true because both condition is true
14>22 && 16>7 : result in false because one condition is false.
This operator is used to combine two conditional expressions. It will result in true if either of two conditions is true otherwise false.
e.g 4>2 || 6>8 : result in true because 4 >2 is true.
14>2 || 6>4 : result in true because 6 >4 is true
14>22 || 16>18 : result in false because both condition is false.
The NOT operator is applied when you want to revert the outcome of an expression.It is a unary operator because it uses a single operand.e.g
!(8>3) : false,because 8>3 is true
!(18>31) : false,because 18<31 is true
!(8<3) : true,because 8<3 is false
Array in Java
Java Array In Java Programming,it becomes necessary to store data within the memory in the most ...read more
Call by Value and call by Reference.
What is Call by Value and Call by Reference in Java Call by value and call ...read more
Operators in Java
Operators In Java Operators are symbols that are used to perform some operations on the operands.They ...read more
Variable in Java
Variable in Java Variable is a name of memory location. Variables are used to hold the ...read more
Modifiers in Java
Modifiers in java There are two types of modifiers in java. 1.Access modifiers 2.Non-access modifiers. 1.Access modifiers Java provides a ...read more
Data Types in Java
Data Types When we create a variable in the program then we reserve some space in ...read more