Thursday, February 12, 2015

Logical Operator

Logical operators are used to perform all the logical operations like and, or not and XOR. Please follow the below example for more details.

package Example1;

public class LogicalOperator {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  if(true && true){
   System.out.println("the value is true");
  }
  if(false || true){
   System.out.println("the value is false");
  }
  if(!(false)){
   System.out.println("the value is true");
  }
  if(true ^ false){
   System.out.println("the value is false");
  }
 }

}


output: the value is true
the value is false
the value is true
the value is false
>>>Ternary
------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment