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);


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.

0 answers