public final class Short extends Number implements Comparable<Short>
Short
类包装的价值在一个对象的原始类型
short
。
Short
类型的对象包含一个字段的类型是
short
。
此外,该类提供了一个short
转换到String
和String
到short
的几种方法,以及其他的一些常量和方法可用于处理一个short
。
Number
,
Serialized Form
Modifier and Type | Field and Description |
---|---|
static int |
BYTES
用于二进制补码形式表示
short 值的字节数。
|
static short |
MAX_VALUE
恒定保持最大值
short 可以有,2
十五-1。
|
static short |
MIN_VALUE
恒持
short 可以有最小值,- 2
十五。
|
static int |
SIZE
用于二进制补码形式表示
short 值的比特数。
|
static 类<Short> |
TYPE
short 代表原始类型的
类 实例。
|
Constructor and Description |
---|
Short(short value)
构建了一个新分配的
Short 表示指定的
short 价值。
|
Short(String s)
构建了一个新分配的
Short 表示
short 值表示的
String 参数。
|
Modifier and Type | Method and Description |
---|---|
byte |
byteValue()
返回该
Short 价值为
byte 缩小原始转换后。
|
static int |
compare(short x, short y)
比较两
short 值的数值。
|
int |
compareTo(Short anotherShort)
比较两
Short 对象数值。
|
static Short |
decode(String nm)
解码
String 成
Short 。
|
double |
doubleValue()
为扩大基本转换后的
double 返回该
Short 价值。
|
boolean |
equals(Object obj)
将此对象与指定的对象进行比较。
|
float |
floatValue()
为扩大基本转换后的
float 返回该
Short 价值。
|
int |
hashCode()
返回此
Short 哈希代码;等于调用
intValue() 结果。
|
static int |
hashCode(short value)
返回一个
short 值的哈希代码兼容
Short.hashCode() 。
|
int |
intValue()
为扩大基本转换后的
int 返回该
Short 价值。
|
long |
longValue()
为扩大基本转换后的
long 返回该
Short 价值。
|
static short |
parseShort(String s)
将字符串参数作为一个符号的十进制
short 。
|
static short |
parseShort(String s, int radix)
将字符串参数作为
short 签署由第二个参数指定的基数。
|
static short |
reverseBytes(short i)
返回通过逆转的二的补码表示指定的
short 值的字节的顺序得到的值。
|
short |
shortValue()
作为一个
short 返回该
Short 价值。
|
String |
toString()
返回表示这
Short 价值
String 对象。
|
static String |
toString(short s)
返回一个新的
String 对象表示指定的
short 。
|
static int |
toUnsignedInt(short x)
转换参数的符号转换
int 。
|
static long |
toUnsignedLong(short x)
转换参数的符号转换
long 。
|
static Short |
valueOf(short s)
返回一个
Short 实例表示指定的
short 价值。
|
static Short |
valueOf(String s)
返回一个
Short 对象持有价值由指定的
String 给定。
|
static Short |
valueOf(String s, int radix)
返回一个
Short 对象持有价值从指定的
String 解析时由第二个参数给定的基数提取。
|
public static final short MIN_VALUE
short
可以有,- 2
十五。
public static final short MAX_VALUE
short
可以有,2
十五-1。
public static final int SIZE
short
值的比特数。
public static final int BYTES
short
值的字节数。
public Short(short value)
Short
表示指定的
short
价值。
value
-被
Short
所代表的值。
public Short(String s) throws NumberFormatException
Short
表示
short
值表示的
String
参数。字符串转换成完全由基数10
parseShort
方法使用的方式
short
价值。
s
-
String
被转换为
Short
NumberFormatException
-如果
String
不包含parsable
short
。
parseShort(java.lang.String, int)
public static String toString(short s)
String
对象表示指定的
short
。基数被假定为10。
s
-
short
要转换
short
Integer.toString(int)
public static short parseShort(String s, int radix) throws NumberFormatException
short
签署由第二个参数指定的基数。字符串中的字符必须是数字,指定的基数(确定是否
Character.digit(char, int)
返回非负价值)除了第一个字符可以是ASCII减号
'-'
(
'\u002D'
)来表示负数或ASCII加号
'+'
(
'\u002B'
)表明一个积极的价值。由此产生的
short
返回值。
如果出现下列情况时抛出的异常类型是NumberFormatException
:
null
或是字符串的长度为零。Character.MAX_RADIX
Character.MIN_RADIX
。'-'
('\u002D'
)或加号'+'
('\u002B'
)提供的字符串长度大于1。short
。s
含有
short
表示要解析的
String
radix
的基数是在分析
s
使用
short
。
NumberFormatException
-如果
String
不包含parsable
short
。
public static short parseShort(String s) throws NumberFormatException
short
。字符串中的字符都必须是十进制数字,除了第一个字符可以是ASCII减号
'-'
(
'\u002D'
)来表示负数或ASCII加号
'+'
(
'\u002B'
)表明一个积极的价值。由此产生的
short
值返回,就像争论和基数为10得到的
parseShort(java.lang.String, int)
方法参数。
s
-
String
含有
short
表示被解析
short
价值。
NumberFormatException
如果字符串不包含parsable
short
。
public static Short valueOf(String s, int radix) throws NumberFormatException
Short
对象持有价值提取指定的
String
解析时由第二个参数给定的基数。第一个参数是解释为代表在签署
short
进制由第二个参数指定,就像争论给
parseShort(java.lang.String, int)
方法。其结果是一个
Short
表示的字符串指定的
short
价值。
换句话说,这个方法返回一个Short
对象相等的价值:
new Short(Short.parseShort(s, radix))
s
-被解析的字符串
radix
-基被用于解释
s
Short
对象持有价值按指定进制表示的字符串参数。
NumberFormatException
-如果
String
不包含parsable
short
。
public static Short valueOf(String s) throws NumberFormatException
Short
对象持有价值由指定的
String
给定。争论的解释是代表一个十进制
short
,就像争论给
parseShort(java.lang.String)
方法。其结果是一个
Short
表示的字符串指定的
short
价值。
换句话说,这个方法返回一个Short
对象相等的价值:
new Short(Short.parseShort(s))
s
-被解析的字符串
Short
对象持有价值为代表的字符串参数
NumberFormatException
-如果
String
不包含parsable
short
。
public static Short valueOf(short s)
short
价值
Short
实例。如果一个新的
Short
实例是不需要的,这种方法一般应优先使用构造函数
Short(short)
,这种方法可能会产生显着更好的空间和时间,通过缓存经常请求的价值表现。此方法将总是在范围内的缓存值- 128至127,包含,并可能缓存在此范围以外的其他值。
s
-短值。
s
Short
实例。
public static Short decode(String nm) throws NumberFormatException
String
成
Short
。接受十进制,十六进制和八进制数由以下的语法:
nulldecimalnumeral,nullhexdigits,和nulloctaldigits是在 The Java™ Language Specification第3.10.1定义,除了强调不接受之间的数字。
- DecodableString:
- Signopt DecimalNumeral
- Signopt
0x
HexDigits- Signopt
0X
HexDigits- Signopt
#
HexDigits- Signopt
0
OctalDigits- Sign:
-
+
的字符序列遵循一个可选的标志和/或基数符(“0x
”、“0X
”、“#
”,或前导零)解析与显示的基数Short.parseShort
法(10,16,或8)。这个序列的字符必须是一个积极的价值或NumberFormatException
将抛出。结果是否定,如果指定的第一个字符是String
负号。没有空格字符是在String
允许。
nm
-
String
解码。
Short
对象持有
short
所代表的价值
nm
NumberFormatException
-如果
String
不包含parsable
short
。
parseShort(java.lang.String, int)
public byte byteValue()
byte
返回该
Short
价值。
public short shortValue()
short
返回该
Short
价值。
shortValue
方法重写,继承类
Number
short
后。
public int intValue()
int
返回该
Short
价值。
public long longValue()
long
返回该
Short
价值。
public float floatValue()
float
返回该
Short
价值。
floatValue
方法重写,继承类
Number
float
后。
public double doubleValue()
double
返回该
Short
价值。
doubleValue
方法重写,继承类
Number
double
后。
public int hashCode()
Short
哈希代码;等于调用
intValue()
结果。
hashCode
方法重写,继承类
Object
Short
哈希代码值
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public static int hashCode(short value)
short
值的哈希代码兼容
Short.hashCode()
。
value
价值-哈希
short
值的哈希码值。
public boolean equals(Object obj)
true
如果只有参数不
null
是
Short
对象包含相同的值作为此对象
short
。
equals
方法重写,继承类
Object
obj
-比较对象
true
如果对象是相同的;
false
否则。
Object.hashCode()
,
HashMap
public int compareTo(Short anotherShort)
Short
对象数值。
compareTo
接口
Comparable<Short>
anotherShort
-
Short
进行比较。
0
如果这
Short
等于参数
Short
;值小于
0
如果这
Short
数值小于参数
Short
;和一个值大于
0
如果这
Short
数值大于论证
Short
(签署的比较)。
public static int compare(short x, short y)
short
值的数值。返回的值是什么将返回相同的:
短。值(x)。CompareTo(短。值(Y))
x
-比较第一
short
y
-比较二
short
0
如果
x == y
;值小于
0
如果
x < y
;和一个值大于
0
如果
x > y
public static short reverseBytes(short i)
short
值的字节的顺序得到的值。
i
的字节被扭转的价值
short
值的字节。
public static int toUnsignedInt(short x)
int
。在一个
int
unsigned转换,高16位的
int
是零和低阶的16位是相等的
short
论点的位。因此,零和正
short
值映射到一个数值等于
int
价值和负
short
值映射到等于输入端加一个
int
2
十六价值。
x
-转换为unsigned
int
价值
int
由符号转换
public static long toUnsignedLong(short x)
long
。在一个
long
unsigned转换,高48位的
long
是零和低阶的16位是相等的
short
论点的位。因此,零和正
short
值映射到一个数值等于
long
价值和负
short
值映射到一个
long
值等于输入加2
十六。
x
-转换为unsigned
long
价值
long
由符号转换
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.