//IntSumWithWildcardDemo.java
//Exactly the same as IntSumWithoutWildcardDemo.java, except for the name.
//And this time every thing compiles!

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

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

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

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

        System.out.println();

        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."
        );
    }
}

