example of logical operators in java
Example 1: Operators in java
public class AssignmentOperatorDemo
{
public static void main(String[] args)
{
int numOne = 60;
int numTwo = 30;
numTwo += numOne;
System.out.println("(+=) : " + numTwo);
numTwo -= numOne;
System.out.println("(-=) : " + numTwo);
numTwo *= numOne;
System.out.println("(*=) : " + numTwo);
numTwo /= numOne;
System.out.println("(/=) : " + numTwo);
numTwo %= numOne;
System.out.println("(%=) : " + numTwo);
}
}
Example 2: Operators in java
public class JavaUnaryOperator
{
public static void main(String[] args)
{
boolean bool = true;
int a = 14, b = 5;
System.out.println("Before using java unary ! operator: " + bool);
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("After using java unary ! operator: " + !bool);
System.out.println("!(a < b) = " + !(a < b));
System.out.println("!(a > b) = " + !(a > b));
}
}