Sample Code
public class UnaryOperator {
public static void main(String[] args) {
// unary operator ++,--
int x = 5;
System.out.println(++x);// pre increment
System.out.println(x);
System.out.println(x++); // post increment
System.out.println(x);
}
}
Example Code
public class Operator2 {
public static void main(String[] args) {
// conditional operator &&, ||
int x = 10;
int y = 20;
int z = 30;
if (x < y && y < z)
System.out.println("greatest" + z);
z = 5;
if (x < y || y < z)
System.out.println("greatest" + z);
// unary operator ++,--
System.out.println(++x);// pre increment
System.out.println(x++); // post
System.out.println(x);
}
}