牢记以下口诀:
short一定是int, 子类一定是父类, 转成一定是的东西就是自动转型
short _short = 1;
int _int = _short; //自动类型转换
short _short2 = (short)_int; //强制类型转换
Father fakeFather = new Son(); //自动向上转型
Son son = (Son)fakeFather; //强制向下转型
牢记以下口诀:
short一定是int, 子类一定是父类, 转成一定是的东西就是自动转型
short _short = 1;
int _int = _short; //自动类型转换
short _short2 = (short)_int; //强制类型转换
Father fakeFather = new Son(); //自动向上转型
Son son = (Son)fakeFather; //强制向下转型