简短的原语
short
是 16 位有符号整数。它的最小值为 -2 15 (-32,768),最大值为 2 15 -1(32,767)
short example = -48;
short myShort = 987;
short anotherShort = 17;
short addedShorts = (short) (myShort + anotherShort); // 1,004
short subtractedShorts = (short) (myShort - anotherShort); // 970
short
的最大值和最小值可在以下位置找到:
short high = Short.MAX_VALUE; // high == 32767
short low = Short.MIN_VALUE; // low == -32768
short
的默认值为 0
short defaultShort; // defaultShort == 0