1 | // 直接产生一个实例(人类) |
上面一句报错:
Exception in thread “main” java.lang.ClassCastException: abstractfactory.yellowHuman.YellowMaleHuman cannot be cast to abstractfactory.Human
原因:
在AbstractYellowHuman类中,
1 | package abstractfactory; |
应该是
1 | package abstractfactory; |