//IntSumWithoutWildcardDemo.java

public class IntSumWithoutWildcardDemo
{
    public static void main(String args[])
    {
        System.out.println();

        Integer intNums[] =
        {
            1, 2, 3, 4, 5
        };
        IntSumWithoutWildcard<Integer> intObject
            = new IntSumWithoutWildcard<>(intNums);
        int iSum = intObject.intSum();
        System.out.println("intObject sum is " + iSum);

        Double doubleNums[] =
        {
            1.1, 2.2, 3.3, 4.4, 5.5
        };
        IntSumWithoutWildcard<Double> doubleObject
            = new IntSumWithoutWildcard<>(doubleNums);
        iSum = doubleObject.intSum();
        System.out.println("doubleObject sum is " + iSum);

        Float floatNums[] =
        {
            1.1f, 2.2f, 3.3f, 4.4f, 5.5f
        };
        IntSumWithoutWildcard<Float> floatObject
            = new IntSumWithoutWildcard<>(floatNums);
        iSum = floatObject.intSum();
        System.out.println("floatObject sum is " + iSum);

        System.out.println();

        //This attempt to compare two integer sums compiles and runs only
        //because the two objects in the second call to println() are of
        //the same type:
        Integer otherIntNums[] =
        {
            11, 1, 1, 1, 1
        };
        IntSumWithoutWildcard<Integer> otherIntObject
            = new IntSumWithoutWildcard<>(otherIntNums);
        iSum = otherIntObject.intSum();
        System.out.println("otherIntObject sum is " + iSum);
        System.out.print("The sums of intObject and otherIntObject are ");
        System.out.println
        (
            intObject.hasSameIntSum(otherIntObject) ? "the same." : "different."
        );

        //But the following three comparison attemps will not compile because
        //in each call to println() the two objects are of different types:
        /*
            System.out.print("The sums of intObject and doubleObject are ");
            System.out.println(intObject.hasSameIntSum(doubleObject)
             ? "the same." : "different.");
            System.out.print("The sums of intObject and floatObject are ");
            System.out.println(intObject.hasSameIntSum(floatObject)
             ? "the same." : "different.");
            System.out.print("The sums of doubleObject and floatObject are ");
            System.out.println(doubleObject.hasSameIntSum(floatObject)
             ? "the same." : "different.");
        */
    }
}
