No it is not - you are instantiating a Dog
, but since a Dog
is an Animal
, you can declare the variable to be an Animal
. If you try to instantiate the interface Animal
it would be:
Animal baby2 = new Animal();
Try that, and watch the compiler scream in horror :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…