operator symbols in java code example
Example 1: Operators in java
public class TernaryOperatorDemo
{
public static void main(String[] args)
{
int a = 50, b = 500, bigger;
System.out.println("First number: " + a);
System.out.println("Second number: " + b);
bigger = (a > b) ? a : b;
System.out.println("Bigger number is = " + bigger);
}
}
Example 2: Operators in java
public class JavaUnaryOperator
{
public static void main(String[] args)
{
int a = 8, b = -4;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println(a + " java bitwise complement is = " + ~a);
System.out.println(b + " java bitwise complement ia = " + ~b);
}
}