public class test {
public static void main(String[] args) {
short s1=1;
short s2=2;
short a =s1+s2; //s1和s2相加会自动转换成int类型,所以是错的
short b =(short)(s1+s2); //把int类型强制转换成short类型,是对的
s1=s1+1; //s1加上1之后变成int类型,而s1是short型,不能自动转换,所以报错
s1=(short)(s1+1);
s1= s1+(short)1; //两个相加之和会变成int类型,而s1是short型,不能自动转换,所以报错
s1=(short) ( s1+(short)1);
s1+=1; //相当于s1=(short)(s1+1);
}
}