//BoxGenericDemo.java
//Demonstrates the BoxGeneric<T> class by creating two
//different class objects, one with an Integer private
//data member, and one with a String private data member.
//Note: No cast is required when retrieving the stored value.

public class BoxGenericDemo
{
    public static void main(String args[])
    {
        System.out.println();

        BoxGeneric<Integer> intObject = new BoxGeneric<>(123);
        intObject.showType();
        int intValue = intObject.getData(); //No cast required
        System.out.println("value: " + intValue);

        System.out.println();

        BoxGeneric<String> stringObject = new BoxGeneric<>("Have a nice day!");
        stringObject.showType();
        String stringValue = stringObject.getData(); //No cast required
        System.out.println("value: " + stringValue);

        //intObject = stringObject;  //Does not compile!
    }
}

/*Output:

The type of t is java.lang.Integer.
value: 123

The type of t is java.lang.String.
value: Have a nice day!
*/
