Rename Reptile to Amphibian
This commit is contained in:
parent
af0db9610e
commit
141f05d179
|
@ -1,6 +1,6 @@
|
||||||
package com.baeldung.exceptions.classcastexception;
|
package com.baeldung.exceptions.classcastexception;
|
||||||
|
|
||||||
public class Reptile implements Animal {
|
public class Amphibian implements Animal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
|
@ -1,6 +1,6 @@
|
||||||
package com.baeldung.exceptions.classcastexception;
|
package com.baeldung.exceptions.classcastexception;
|
||||||
|
|
||||||
public class Frog extends Reptile {
|
public class Frog extends Amphibian {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class CheckedCastsUnitTest {
|
||||||
Animal animal = new Frog();
|
Animal animal = new Frog();
|
||||||
|
|
||||||
//A checked downcast to Mammal is incompatible from Frog because Frog is not a subtype of Mammal.
|
//A checked downcast to Mammal is incompatible from Frog because Frog is not a subtype of Mammal.
|
||||||
Mammal mammal = (Mammal) animal;
|
Mammal mammal1 = (Mammal) animal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = ClassCastException.class)
|
@Test(expected = ClassCastException.class)
|
||||||
|
|
Loading…
Reference in New Issue