Integer.ValueOf Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ValueOf(Int32) |
Returns an |
ValueOf(String) |
Returns an |
ValueOf(String, Int32) |
Returns an |
ValueOf(Int32)
Returns an Integer
instance representing the specified
int
value.
[Android.Runtime.Register("valueOf", "(I)Ljava/lang/Integer;", "")]
public static Java.Lang.Integer ValueOf (int i);
[<Android.Runtime.Register("valueOf", "(I)Ljava/lang/Integer;", "")>]
static member ValueOf : int -> Java.Lang.Integer
Parameters
- i
- Int32
an int
value.
Returns
an Integer
instance representing i
.
- Attributes
Remarks
Returns an Integer
instance representing the specified int
value. If a new Integer
instance is not required, this method should generally be used in preference to the constructor #Integer(int)
, as this method is likely to yield significantly better space and time performance by caching frequently requested values.
This method will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range.
Added in 1.5.
Java documentation for java.lang.Integer.valueOf(int)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
ValueOf(String)
Returns an Integer
object holding the
value of the specified String
.
[Android.Runtime.Register("valueOf", "(Ljava/lang/String;)Ljava/lang/Integer;", "")]
public static Java.Lang.Integer ValueOf (string s);
[<Android.Runtime.Register("valueOf", "(Ljava/lang/String;)Ljava/lang/Integer;", "")>]
static member ValueOf : string -> Java.Lang.Integer
Parameters
- s
- String
the string to be parsed.
Returns
an Integer
object holding the value
represented by the string argument.
- Attributes
Exceptions
if string
cannot be parsed as an integer value.
Remarks
Returns an Integer
object holding the value of the specified String
. The argument is interpreted as representing a signed decimal integer, exactly as if the argument were given to the #parseInt(java.lang.String)
method. The result is an Integer
object that represents the integer value specified by the string.
In other words, this method returns an Integer
object equal to the value of:
<blockquote> new Integer(Integer.parseInt(s))
</blockquote>
Java documentation for java.lang.Integer.valueOf(java.lang.String)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
See also
Applies to
ValueOf(String, Int32)
Returns an Integer
object holding the value
extracted from the specified String
when parsed
with the radix given by the second argument.
[Android.Runtime.Register("valueOf", "(Ljava/lang/String;I)Ljava/lang/Integer;", "")]
public static Java.Lang.Integer ValueOf (string s, int radix);
[<Android.Runtime.Register("valueOf", "(Ljava/lang/String;I)Ljava/lang/Integer;", "")>]
static member ValueOf : string * int -> Java.Lang.Integer
Parameters
- s
- String
the string to be parsed.
- radix
- Int32
the radix to be used in interpreting s
Returns
an Integer
object holding the value
represented by the string argument in the specified
radix.
- Attributes
Exceptions
if string
cannot be parsed as an integer value, or
radix Character.MAX_RADIX
.
Remarks
Returns an Integer
object holding the value extracted from the specified String
when parsed with the radix given by the second argument. The first argument is interpreted as representing a signed integer in the radix specified by the second argument, exactly as if the arguments were given to the #parseInt(java.lang.String, int)
method. The result is an Integer
object that represents the integer value specified by the string.
In other words, this method returns an Integer
object equal to the value of:
<blockquote> new Integer(Integer.parseInt(s, radix))
</blockquote>
Java documentation for java.lang.Integer.valueOf(java.lang.String, int)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
See also
- <xref:Java.Lang.Integer.ParseInt(System.String%2c+System.Int32)>