Short 基本数据类型short 的包装类
Short 类型的对象包含一个 short 类型的字段
原文地址:
[五]基础数据类型之Short详解
属性简介
| 值为 215-1 的常量,它表示 short 类型能够表示的最大值 public static final short MAX_VALUE = 32767; |
| 值为 -215 的常量,它表示 short 类型能够表示的最小值 public static final short MIN_VALUE = -32768; |
| 用来以二进制补码形式表示 short 值的比特位数 public static final int SIZE = 16; |
| 二进制补码形式表示 short 值的字节数 public static final int BYTES = SIZE / Byte.SIZE; |
| 表示基本类型 short 的 Class 实例 public static final Class<Short> TYPE = (Class<Short>) Class.getPrimitiveClass("short"); |
构造方法
照常两种形式
常用方法
比较
|
static int compare(short x, short y)
静态方法
x<y 小于0
x=y 等于0
x>y 大于0
![]() |
| int compareTo(Short anotherShort) 实例方法 调用静态方法比较两个对象的值 |
parseXXX系列
parseShort系列依赖Integer.parseInt
valueOf系列
static Short valueOf(short s)![]() |
static Short valueOf(String s, int radix)![]() |
static Short valueOf(String s) |
XXXValue系列
| 类似 Integer和Long Byte Short也有提供XXXValue系列方法,原理也跟他们类似 全部都是强转 |
|
byteValue()
shortValue()
intValue()
longValue()
floatValue()
doubleValue()
|
toUnsignedXXX 系列
toString 系列
static String toString(short s)![]() |
String toString()![]() |
static int toUnsignedInt(short x) ![]() |
static long toUnsignedLong(short x) |
equals
hashCode
Short的hashcode 也是直接返回值
其他方法
Short提供了reverseBytes(short) 方法
Short虽然比Byte稍微提供的支持多一点点,但是也很少
有些方法也是依赖于Integer

![image_5bb07fe4_68cf[4] image_5bb07fe4_68cf[4]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDA4NzctMTM4Mjc3MDMzMi5wbmc=.png)
![image_5bb07fe4_5e72[4] image_5bb07fe4_5e72[4]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDE2NTEtMTg5Nzg4NjQucG5n.png)
![image_5bb07fe4_464[4] image_5bb07fe4_464[4]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDI2NzktNzAyMjUyOTk0LnBuZw==.png)
![image_5bb07fe4_2762[4] image_5bb07fe4_2762[4]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDMwNzEtMzc0NzQ1ODQ0LnBuZw==.png)
![image_5bb07fe4_5649[4] image_5bb07fe4_5649[4]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDM0NTItNjQ5NTg4MTAucG5n.png)
![image_5bb07fe4_3f74[4] image_5bb07fe4_3f74[4]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDM4ODAtNjE0MDY2OTM5LnBuZw==.png)
![image_5bb07fe4_2a3e[3] image_5bb07fe4_2a3e[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDQyODctODQ5NDI2MzQ4LnBuZw==.png)
![image_5bb07fe4_1f2d[3] image_5bb07fe4_1f2d[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDQ3ODAtMTMwNTA3Njk3OS5wbmc=.png)
![image_5bb07fe4_67ee[3] image_5bb07fe4_67ee[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDUxMTYtNTI3NTM3NDcyLnBuZw==.png)
![image_5bb07fe4_b0[3] image_5bb07fe4_b0[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDU0ODQtNTc2MjkwMjY5LnBuZw==.png)
![image_5bb07fe4_604d[3] image_5bb07fe4_604d[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDU4NzktMTg3NTY0MTA4OC5wbmc=.png)
![image_5bb07fe4_7af9[3] image_5bb07fe4_7af9[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDYyNDctMTQ2Mzg1NDAyMi5wbmc=.png)
![image_5bb07fe4_18db[3] image_5bb07fe4_18db[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDY2MzAtMjAwNDA3NTAzNS5wbmc=.png)
![image_5bb07fe4_6637[3] image_5bb07fe4_6637[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDcxMjctMTk1Mzk3MzI1Ni5wbmc=.png)
![image_5bb07fe4_7709[3] image_5bb07fe4_7709[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDc0NjYtMTQxMjAxNTQ5OS5wbmc=.png)
![image_5bb07fe4_500c[3] image_5bb07fe4_500c[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDc4MTQtMjA2MzM3MjM5My5wbmc=.png)
![image_5bb07fe4_a[3] image_5bb07fe4_a[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDgyMjktNjUwNjM5MzQxLnBuZw==.png)
![image_5bb07fe4_17d9[3] image_5bb07fe4_17d9[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDg2MDItODY2MzY3NDA3LnBuZw==.png)
![image_5bb07fe4_3a43[3] image_5bb07fe4_3a43[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDg5NDEtMTA5ODI2MTQxLnBuZw==.png)
![image_5bb07fe4_41b8[3] image_5bb07fe4_41b8[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDk0MjUtMTI0MjIzMzc2LnBuZw==.png)
![image_5bb07fe4_6dee[3] image_5bb07fe4_6dee[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMDk3ODUtMTM5NDQzNDIxNS5wbmc=.png)
![image_5bb07fe4_357f[3] image_5bb07fe4_357f[3]](/image/aHR0cHM6Ly9pbWcyMDE4LmNuYmxvZ3MuY29tL2Jsb2cvODk3MzkzLzIwMTgwOS84OTczOTMtMjAxODA5MzAxNTUyMTAyMDctNjIwNTQ1MjE3LnBuZw==.png)