Take a look at the following non-generic class:
class NonGenericClass {
private Object val;
public NonGenericClass(Object val) {
this.val = val;
}
public Object get() {
return val;
}
}
And here is the instance of this class:
NonGenericClass instance = new NonGenericClass("Hello");
Now we want to get the string back. When will the code throw a runtime exception?