Created
January 12, 2017 21:13
-
-
Save goaquin/d184a6167690918df142ddad46230bbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CLASS { | |
protected Father bar; | |
public Father bar() | |
{ | |
return this.bar; | |
} | |
} | |
public class Father { | |
... | |
} | |
public class Son | |
extends Father | |
{ | |
... | |
} | |
public class GrandSon1 | |
extends Son | |
{ | |
... | |
} | |
public class GrandSon2 | |
extends Son | |
{ | |
... | |
} | |
public class Code { | |
public main{ | |
Father A = foo.bar(); | |
GrandSon1 B = (GrandSon1)A; | |
} | |
} | |
//This give me the error: | |
//"Cannot cast B to A because B type is GrandSon2." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment