s=s+1とs+=1の違い
直接コード解釈
/**
* :
* short s = 1;
* s = s + 1;
*
* short s = 1;
* s += 1;
*
* , , ?
* @author wangjg
*
*/
public class OperatorTest {
public static void main(String[] args) {
/**
* Type mismatch: cannot convert from int to short
* ,s short , ,s int,int int int
* short,
*/
// short s = 1;
// s = s + 1;
// System.out.println(s);
/**
* += , += , class
* s += 1;
*
* s = (short)(s + 1);
*/
short s = 1;
s += 1;
System.out.println(s);
}
}