Sdílet prostřednictvím


Integer Class

Definition

The Integer class wraps a value of the primitive type int in an object.

[Android.Runtime.Register("java/lang/Integer", DoNotGenerateAcw=true)]
public sealed class Integer : Java.Lang.Number, IConvertible, IDisposable, Java.Interop.IJavaPeerable, Java.Lang.IComparable
[<Android.Runtime.Register("java/lang/Integer", DoNotGenerateAcw=true)>]
type Integer = class
    inherit Number
    interface IConvertible
    interface IComparable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Integer
Attributes
Implements

Remarks

The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.

In addition, this class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods useful when dealing with an int.

<!-- Android-removed: paragraph on ValueBased

This is a value-based class; programmers should treat instances that are #equals(Object) equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail. -->

Implementation note: The implementations of the "bit twiddling" methods (such as #highestOneBit(int) highestOneBit and #numberOfTrailingZeros(int) numberOfTrailingZeros) are based on material from Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002).

Added in 1.0.

Java documentation for java.lang.Integer.

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.

Constructors

Integer(Int32)

Constructs a newly allocated Integer object that represents the specified int value.

Integer(String)

Constructs a newly allocated Integer object that represents the int value indicated by the String parameter.

Fields

Bytes

The number of bytes used to represent an int value in two's complement binary form.

MaxValue

A constant holding the maximum value an int can have, 2<sup>31</sup>-1.

MinValue

A constant holding the minimum value an int can have, -2<sup>31</sup>.

Size

The number of bits used to represent an int value in two's complement binary form.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Number)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Number)
Type

The Class instance representing the primitive type int.

Methods

BitCount(Int32)

Returns the number of one-bits in the two's complement binary representation of the specified int value.

ByteValue()

Returns the value of the specified number as a byte.

(Inherited from Number)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Compare(Int32, Int32)

Compares two int values numerically.

CompareTo(Integer)

Compares two Integer objects numerically.

CompareUnsigned(Int32, Int32)

Compares two int values numerically treating the values as unsigned.

Decode(String)

Decodes a String into an Integer.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
DivideUnsigned(Int32, Int32)

Returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.

DoubleValue()

Returns the value of this Integer as a double after a widening primitive conversion.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FloatValue()

Returns the value of this Integer as a float after a widening primitive conversion.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetInteger(String, Int32)

Determines the integer value of the system property with the specified name.

GetInteger(String, Integer)

Returns the integer value of the system property with the specified name.

GetInteger(String)

Determines the integer value of the system property with the specified name.

HashCode(Int32)

Returns a hash code for an int value; compatible with Integer.hashCode().

HighestOneBit(Int32)

Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int value.

IntValue()

Returns the value of this Integer as an int.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LongValue()

Returns the value of this Integer as a long after a widening primitive conversion.

LowestOneBit(Int32)

Returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified int value.

Max(Int32, Int32)

Returns the greater of two int values as if by calling Math#max(int, int) Math.max.

Min(Int32, Int32)

Returns the smaller of two int values as if by calling Math#min(int, int) Math.min.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
NumberOfLeadingZeros(Int32)

Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified int value.

NumberOfTrailingZeros(Int32)

Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified int value.

ParseInt(ICharSequence, Int32, Int32, Int32)

Parses the CharSequence argument as a signed int in the specified radix, beginning at the specified beginIndex and extending to endIndex - 1.

ParseInt(String, Int32, Int32, Int32)

Parses the CharSequence argument as a signed int in the specified radix, beginning at the specified beginIndex and extending to endIndex - 1.

ParseInt(String, Int32)

Parses the string argument as a signed integer in the radix specified by the second argument.

ParseInt(String)

Parses the string argument as a signed decimal integer.

ParseUnsignedInt(ICharSequence, Int32, Int32, Int32)

Parses the CharSequence argument as an unsigned int in the specified radix, beginning at the specified beginIndex and extending to endIndex - 1.

ParseUnsignedInt(String, Int32, Int32, Int32)

Parses the CharSequence argument as an unsigned int in the specified radix, beginning at the specified beginIndex and extending to endIndex - 1.

ParseUnsignedInt(String, Int32)

Parses the string argument as an unsigned integer in the radix specified by the second argument.

ParseUnsignedInt(String)

Parses the string argument as an unsigned decimal integer.

RemainderUnsigned(Int32, Int32)

Returns the unsigned remainder from dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.

Reverse(Int32)

Returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specified int value.

ReverseBytes(Int32)

Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified int value.

RotateLeft(Int32, Int32)

Returns the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits.

RotateRight(Int32, Int32)

Returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ShortValue()

Returns the value of the specified number as a short.

(Inherited from Number)
Signum(Int32)

Returns the signum function of the specified int value.

Sum(Int32, Int32)

Adds two integers together as per the + operator.

ToArray<T>() (Inherited from Object)
ToBinaryString(Int32)

Returns a string representation of the integer argument as an unsigned integer in base&nbsp;2.

ToHexString(Int32)

Returns a string representation of the integer argument as an unsigned integer in base&nbsp;16.

ToOctalString(Int32)

Returns a string representation of the integer argument as an unsigned integer in base&nbsp;8.

ToString()

Returns a string representation of the object.

(Inherited from Object)
ToString(Int32, Int32)

Returns a string representation of the first argument in the radix specified by the second argument.

ToString(Int32)

Returns a String object representing the specified integer.

ToUnsignedLong(Int32)

Converts the argument to a long by an unsigned conversion.

ToUnsignedString(Int32, Int32)

Returns a string representation of the first argument as an unsigned integer value in the radix specified by the second argument.

ToUnsignedString(Int32)

Returns a string representation of the argument as an unsigned decimal value.

UnregisterFromRuntime() (Inherited from Object)
ValueOf(Int32)

Returns an Integer instance representing the specified int value.

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.

ValueOf(String)

Returns an Integer object holding the value of the specified String.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Operators

Explicit(Integer to Int32)

Explicit Interface Implementations

IComparable.CompareTo(Object)
IConvertible.GetTypeCode()
IConvertible.ToBoolean(IFormatProvider)
IConvertible.ToByte(IFormatProvider)
IConvertible.ToChar(IFormatProvider)
IConvertible.ToDateTime(IFormatProvider)
IConvertible.ToDecimal(IFormatProvider)
IConvertible.ToDouble(IFormatProvider)
IConvertible.ToInt16(IFormatProvider)
IConvertible.ToInt32(IFormatProvider)
IConvertible.ToInt64(IFormatProvider)
IConvertible.ToSByte(IFormatProvider)
IConvertible.ToSingle(IFormatProvider)
IConvertible.ToString(IFormatProvider)
IConvertible.ToType(Type, IFormatProvider)
IConvertible.ToUInt16(IFormatProvider)
IConvertible.ToUInt32(IFormatProvider)
IConvertible.ToUInt64(IFormatProvider)
IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to