What is the problem with the following example and does it compile?

class Animal<T> {
T animal;
Integer age;
public Animal(T animal, Integer age) {
this.animal = animal;
this.age = age;
new Animal(123, 123);
1 answers

The problem is that the constructor is used without the type defined in the class definition. This leads to some warnings, but the code will still compile.

shilpigupta22 shilpigupta22 [Author] 7 months ago votes 0