Wednesday 10 June 2015

Equality And Relational Operators 2

public class ComparisonDemo2 {
        /* > greater than
         * >= greater than or equal to
         * < less than
         * <= less than or equal to
         */
        public static void main(String[] args) {
                int A = 1;
                int B = 0;

                // Test if A is greater than B.
                if(A > B)
                        System.out.println("A is greater than B.");

                // Test if A is greater than or equal to B;
                if(A >= B)
                        System.out.println("A is greather than or equal to B.");

                ++B; // Increment B.

                // Test if A is greater than or equal to B.
                if(A >= B)
                        System.out.println("A is greather than or equal to B.");

                // Test if A is less than or equal to B.
                if(A <= B)
                        System.out.println("A is less than or equal to B.");

                --A; // Decrement A.

                // Test if A is less than or equal to B.
                if(A <= B)
                        System.out.println("A is less than or equal to B.");

                // Test if A is less than B.
                if(A < B)
                        System.out.println("A is less than B.");
        }
}

No comments:

Post a Comment

Translate