Skip to content

Instantly share code, notes, and snippets.

@goaquin
Created January 12, 2017 21:13
Show Gist options
  • Save goaquin/d184a6167690918df142ddad46230bbd to your computer and use it in GitHub Desktop.
Save goaquin/d184a6167690918df142ddad46230bbd to your computer and use it in GitHub Desktop.
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