語言

Integer.GetInteger 方法

定義

多載

名稱 Description
GetInteger(String)

決定系統屬性的整數值,並指定名稱。

GetInteger(String, Integer)

回傳系統屬性的整數值,並以指定名稱。

GetInteger(String, Int32)

決定系統屬性的整數值,並指定名稱。

GetInteger(String)

決定系統屬性的整數值,並指定名稱。

[Android.Runtime.Register("getInteger", "(Ljava/lang/String;)Ljava/lang/Integer;", "")]
public static Java.Lang.Integer? GetInteger(string nm);
[<Android.Runtime.Register("getInteger", "(Ljava/lang/String;)Ljava/lang/Integer;", "")>]
static member GetInteger : string -> Java.Lang.Integer

參數

nm
String

財產名稱。

傳回

財產 Integer 的價值。

屬性

備註

決定系統屬性的整數值,並指定名稱。

第一個參數被視為系統屬性的名稱。 系統屬性可透過此 java.lang.System#getProperty(java.lang.String) 方法存取。 此屬性的字串值會被解讀為整數值,並利用所支持Integer#decode decodeInteger的文法,並回傳一個代表該值的物件。

若不存在指定名稱的屬性,或該名稱為空 null或 ,或屬性的數值格式不正確,則 null 返回 。

換句話說,此方法回傳 Integer 的物件值為:

<引用>getInteger(nm, null)</引用>

Java 文件 java.lang.Integer.getInteger(java.lang.String)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

GetInteger(String, Integer)

回傳系統屬性的整數值,並以指定名稱。

[Android.Runtime.Register("getInteger", "(Ljava/lang/String;Ljava/lang/Integer;)Ljava/lang/Integer;", "")]
public static Java.Lang.Integer? GetInteger(string nm, Java.Lang.Integer? val);
[<Android.Runtime.Register("getInteger", "(Ljava/lang/String;Ljava/lang/Integer;)Ljava/lang/Integer;", "")>]
static member GetInteger : string * Java.Lang.Integer -> Java.Lang.Integer

參數

nm
String

財產名稱。

val
Integer

預設值。

傳回

財產 Integer 的價值。

屬性

備註

回傳系統屬性的整數值,並以指定名稱。 第一個參數被視為系統屬性的名稱。 系統屬性可透過此 java.lang.System#getProperty(java.lang.String) 方法存取。 此屬性的字串值會依照方法 Integer#decode decode 被解讀為整數值,並 Integer 回傳代表該值的物件;總結如下:

<ul><li>如果屬性值以兩個 ASCII 字元 0x 或 ASCII 字元 #開頭,且不後接負號,則其餘部分會依基數 16 的方法精確解析為十六進位 #valueOf(java.lang.String, int) 整數。 <li>如果屬性值以 ASCII 字元 0 開頭,後接另一個字元,則會以八進位整數解析,與 #valueOf(java.lang.String, int) 基數 8 的方法完全相同。 <否則>,性質值會以十進位整數解析,與 #valueOf(java.lang.String, int) 基數 10 的方法完全相同。 </ul>

第二個論點是預設值。 若指定名稱中沒有屬性、該屬性的數值格式不正確,或指定名稱為空或 null,則會回傳預設值。

Java 文件 java.lang.Integer.getInteger(java.lang.String, java.lang.Integer)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

GetInteger(String, Int32)

決定系統屬性的整數值,並指定名稱。

[Android.Runtime.Register("getInteger", "(Ljava/lang/String;I)Ljava/lang/Integer;", "")]
public static Java.Lang.Integer? GetInteger(string nm, int val);
[<Android.Runtime.Register("getInteger", "(Ljava/lang/String;I)Ljava/lang/Integer;", "")>]
static member GetInteger : string * int -> Java.Lang.Integer

參數

nm
String

財產名稱。

val
Int32

預設值。

傳回

財產 Integer 的價值。

屬性

備註

決定系統屬性的整數值,並指定名稱。

第一個參數被視為系統屬性的名稱。 系統屬性可透過此 java.lang.System#getProperty(java.lang.String) 方法存取。 此屬性的字串值會被解讀為整數值,並利用所支持Integer#decode decodeInteger的文法,並回傳一個代表該值的物件。

第二個論點是預設值。 Integer若指定名稱沒有屬性、屬性的數值不正確,或指定名稱為空或 null,則回傳代表第二個參數值的物件。

換句話說,此方法回傳 Integer 的物件值為:

<引用>getInteger(nm, Integer.valueOf(val))</引用>

但在實務上,它可以以以下方式實作:

<引用>

Integer result = getInteger(nm, null);
            return (result == null) ? Integer.valueOf(val) : result;

</區塊引用>

以避免在不需要預設值時,物件配置不必要 Integer 。

Java 文件 java.lang.Integer.getInteger(java.lang.String, int)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於