|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.lang.Number
java.lang.Short
public final class Short
Short 類別在物件中包裹基本型別 short 的值。一個 Short 型別的物件只包含一個 short 型別的欄位。
另外,該類別提供了多個方法,可以將 short 轉換為 String,將 String 轉換為 short,同時還提供了其他一些處理 short 時有用的常數和方法。
Number,
序列化表格| 欄位摘要 | |
|---|---|
static short |
MAX_VALUE
保存 short 可取的最大值的常數,最大值為 215-1。 |
static short |
MIN_VALUE
保存 short 可取的最小值的常數,最小值為 -215。 |
static int |
SIZE
用來以二進制補碼形式表示 short 值的位數。 |
static Class<Short> |
TYPE
表示基本型別 short 的 Class 實例。 |
| 建構子摘要 | |
|---|---|
Short(short value)
建構一個新分派的 Short 物件,用來表示指定的 short 值。 |
|
Short(String s)
建構一個新分派的 Short 物件,用來表示 String 參數所指示的 short 值。 |
|
| 方法摘要 | |
|---|---|
byte |
byteValue()
以 byte 形式返回此 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 的雜湊碼。 |
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)
返回表示指定 short 的一個新 String 物件。 |
static Short |
valueOf(short s)
返回表示指定 short 值的 Short 實例。 |
static Short |
valueOf(String s)
返回一個保持指定 String 所給出的值的 Short 物件。 |
static Short |
valueOf(String s,
int radix)
返回一個 Short 物件,該物件保持從指定的 String 中提取的值,該值是在使用第二個參數給出的進制對指定字元串進行解析時提取的。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| 欄位詳細資訊 |
|---|
public static final short MIN_VALUE
short 可取的最小值的常數,最小值為 -215。
public static final short MAX_VALUE
short 可取的最大值的常數,最大值為 215-1。
public static final Class<Short> TYPE
short 的 Class 實例。
public static final int SIZE
| 建構子詳細資訊 |
|---|
public Short(short value)
Short 物件,用來表示指定的 short 值。
valueShort - 所表示的值。
public Short(String s)
throws NumberFormatException
Short 物件,用來表示 String 參數所指示的 short 值。將字元串轉換為 short 值,轉換方式與進制為 10 的 parseShort 方法所用的方式完全相同。
s - 要轉換為 Short 的 String
NumberFormatException - 如果 String 不包含可解析的 short。parseShort(java.lang.String, int)| 方法詳細資訊 |
|---|
public static String toString(short s)
short 的一個新 String 物件。假定用十進製表示。
s - 所要轉換的 short
short 的字元串Integer.toString(int)
public static short parseShort(String s)
throws NumberFormatException
short。該字元串中的字元必須都是十進制數字,除非第一個字元是表示負值的 ASCII 符號中的負號 '-' ('\u002D')。返回得到的 short 值,此值與用該參數和進制 10 作為參數的 parseShort(java.lang.String, int) 方法得到的值相同。
s - 套件含要解析的 short 表示形式的 String
short 值。
NumberFormatException - 如果該字元串不包含可解析的 short。
public static short parseShort(String s,
int radix)
throws NumberFormatException
short。該字元串中的字元必須都是指定進制(這取決於 Character.digit(char, int) 是否返回非負值)的數字,除非第一個字元是表示負值的 ASCII 符號中的負號 “-” ('\u002D')。返回得到的 byte 值。
如果出現以下情形之一,則拋出 NumberFormatException 型別的異常:
null 或零長度的字元串。
Character.MIN_RADIX 或大於 Character.MAX_RADIX。
“-” ('\u002D') 之外,字元串的任何字元都不是指定進制的數字。
short 型別的值。
s - 套件含要解析的 short 表示形式的 Stringradix - 將在解析 s 時使用的進制
short。
NumberFormatException - 如果 String 不包含可解析的 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 不包含可解析的 short。
public static Short valueOf(String s)
throws NumberFormatException
String 所給出的值的 Short 物件。該參數被解釋為表示一個有符號的十進制 short,此值與用該參數作為參數的 #parseLong(java.lang.String) 方法得到的值相同。結果是一個表示該字元串所指定的 short 值的 Short 物件。 換句話說,此方法返回一個 Short 物件,它的值等於:
new Short(Short.parseShort(s))
s - 要解析的字元串
Short 物件
NumberFormatException - 如果 String 不包含可解析的 short。public static Short valueOf(short s)
Short(short),因為此方法很可能通過快取記憶體經常請求的值來顯著提高空間和時間性能。
s - 一個 short 值。
public static Short decode(String nm)
throws NumberFormatException
String 解碼為 Short。接受通過以下語法給出的十進制、十六進制和八進制數:
DecimalNumeral、HexDigits 和 OctalDigits 在 Java Language Specification 的 §3.10.1 中已經定義。
- DecodableString:
- Signopt DecimalNumeral
- Signopt
0xHexDigits- Signopt
0XHexDigits- Signopt
#HexDigits- Signopt
0OctalDigits
- Sign:
-
對(可選)負號和/或進制說明符(“0x”、“0X”、“#” 或前導零)後面的字元序列進行解析就如同用 Short.parseByte 方法來解析指定的進制(10、16 或 8)一樣。該字元序列必須表示為一個正值,否則將拋出 NumberFormatException。如果指定 String 的第一個字元是減號,則結果無效。String 中不允許出現空白字元。
nm - 要解碼的 String。
nm 所表示的 short 值的 Short 物件
NumberFormatException - 如果 String 不包含可解析的 short。parseShort(java.lang.String, int)public byte byteValue()
byte 形式返回此 Short 的值。
Number 中的 byteValuebyte 型別後該物件表示的數值。public short shortValue()
short 形式返回此 Short 的值。
Number 中的 shortValueshort 型別後該物件表示的數值。public int intValue()
int 形式返回此 Short 的值。
Number 中的 intValueint 型別後該物件表示的數值。public long longValue()
Long 形式返回此 Short 的值。
Number 中的 longValuelong 型別後該物件表示的數值。public float floatValue()
float 形式返回此 Short 的值。
Number 中的 floatValuefloat 型別後該物件表示的數值。public double doubleValue()
double 形式返回此 Short 的值。
Number 中的 doubleValuedouble 型別後該物件表示的數值。public String toString()
Short 的值的 String 物件。該值被轉換成有符號的十進製表示形式,並作為一個字元串返回,正如將 short 值作為一個參數指定給 toString(short) 方法所得到的值那樣。
Object 中的 toStringpublic int hashCode()
Short 的雜湊碼。
Object 中的 hashCodeObject.equals(java.lang.Object),
Hashtablepublic boolean equals(Object obj)
null,而是一個與該物件一樣包含相同 short 值的 Short 物件時,結果才為 true。
Object 中的 equalsobj - 將與之進行比較的物件。
true;否則返回 false。Object.hashCode(),
Hashtablepublic int compareTo(Short anotherShort)
Short 物件所表示的數值。
Comparable<Short> 中的 compareToanotherShort - 要比較的 Short。
Short 等於參數 Short,則返回 0;如果該 Short 數值小於參數 Short,則返回小於 0 的值;如果該 Short 數值大於參數 Short,則返回大於 0 的值(有符號比較)。public static short reverseBytes(short i)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。