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
0xHexDigits- Signopt
0XHexDigits- Signopt
#HexDigits- Signopt
0OctalDigits- 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.