package arithmetic;

public class ArithmeticExcample {

    public static void main(String[] args) {

        // prints 2

        System.out.println(1+1);

        // prints 5

        System.out.println(1+2*2);

        // prints 6

        System.out.println((1+2)*2);

        // prints 1

        System.out.println(10%3);

        // prints 3

        System.out.println(10/3);

        // prints 3.3333333333333335

        System.out.println(10.0/3);

    }

}

 

 

 

package unary;

public class UnaryExample {

    public static void main(String[] args) {

        int num = 10;

        int num2 = num++;

        int num3 = ++num;

        System.out.println(num2);

        System.out.println(num3);

    }

}

 

 

 

 

package comparison;

public class Equality {

    public static void main(String[] args) {

        System.out.println(1==1);

        System.out.println(1==1.0);

        System.out.println(1!=2.0);

           

        StringBuffer sb1 = new StringBuffer("Hello");

        StringBuffer sb2 = new StringBuffer("Hello");

        StringBuffer sb3 = sb1;

        System.out.println(sb1 == sb3);

        System.out.println(sb1 != sb2);        

           

        System.out.println("hello" == "hello");

        System.out.println(new String("hello") != new String("hello"));

           

        System.out.println("hello" instanceof String );

        System.out.println(sb2 instanceof StringBuffer );  

    }

}

 

 

 

 

package comparison;

public class Relational {

    public static void main(String[] args) {

        System.out.println(1 >= 1);

        System.out.println(2 > 1.0);

        System.out.println(1.99999 < 2);

        System.out.println(1.9 <= 2.0);

    }

}

 

 

 

 

package conditional;

 

public class ConditionalExample {

    public static void main(String[] args) {

        System.out.println(true && true);

        System.out.println(1 > 0 && 1 >= 1);

        System.out.println((0 > 1 && 0 > 2) || 0 == 0);

        System.out.println("hello".length() == 5

            && "hello".charAt(0) == 'h');

        int[] nums = {};

        System.out.println(nums.length == 0 || nums[1] > 5);

    }

}