Integer class

                              
    java.lang.Object                         
     |                        
     |--java.lang.Number                     
         |                    
         |--java.lang.Integer                 
                              

The Integer class wraps a value of the primitive type int. Integer class provides several methods for converting an int to a String and a String to an int.

TypeFieldSummary
static intMAX_VALUEMaximum value an int can have.
static intMIN_VALUEMinimum value an int can have.
static intSIZEThe number of bits used to represent an int value.
static ClassTYPEThe Class instance representing the primitive type int.

Constructor Summary

ConstructorSummary
Integer(int value)Creates an Integer object for the int value.
Integer(String s)Creates an Integer object for the int value indicated by the String parameter.

Return an integer value as byte, double, float, int, long and short

ReturnMethodSummary
bytebyteValue()Returns this Integer as a byte.
doubledoubleValue()Returns this Integer as a double.
floatfloatValue()Returns this Integer as a float.
intintValue()Returns this Integer as an int.
longlongValue()Returns this Integer as a long.
shortshortValue()Returns this Integer as a short.

Compare two integer values

ReturnMethodSummary
intcompareTo(Integer anotherInteger)Compares two Integer objects numerically.
booleanequals(Object obj)Compares this object to the specified object.

Decode a string and return an integer value

ReturnMethodSummary
static Integerdecode(String nm)Decodes a String into an Integer.

Convert string to integer

ReturnMethodSummary
static intparseInt(String s)Parses the string argument as a signed decimal integer.
static intparseInt(String s, int radix)Parses the string argument in the radix.
static IntegervalueOf(int i)Returns a Integer instance representing the int value.
static IntegervalueOf(String s)Returns an Integer holding the value of the String.
static IntegervalueOf(String s, int radix)Returns an Integer from String based on the radix.

Convert integer to string

ReturnMethodSummary
StringtoString()Returns a String object representing this Integer's value.
static StringtoString(int i)Returns a String object representing the specified integer.
static StringtoString(int i, int radix)Returns a string representation of i in radix.

Reverse and rotate the integer in binary format

ReturnMethodSummary
static intreverse(int i)Reversing the bits.
static intreverseBytes(int i)Reversing the bytes.
static introtateLeft(int i, int distance)Rotating the bits by distance.
static introtateRight(int i, int distance)Rotating the bits by distance.

Bit oriented operation

ReturnMethodSummary
static intbitCount(int i)Count bits in the binary representation of the specified int value.
static inthighestOneBit(int i)Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit.
static intlowestOneBit(int i)Returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit.

Return system property as integer

ReturnMethodSummary
static IntegergetInteger(String nm)Get the system property.
static IntegergetInteger(String nm, int val)Get the integer value of the system property with a default value.
static IntegergetInteger(String nm, Integer val)Returns the integer value of the system property with a default value.

Get the leading and trailing zeros

ReturnMethodSummary
static intnumberOfLeadingZeros(int i)Returns the number of zero bits preceding the highest-order ("leftmost") one-bit.
static intnumberOfTrailingZeros(int i)Returns the number of zero bits following the lowest-order ("rightmost") one-bit.

Get the sign

ReturnMethodSummary
static intsignum(int i)Returns the sign.

Convert integer to binary, hexdecimal and octal format

ReturnMethodSummary
static StringtoBinaryString(int i)Return the binary string for i.
static StringtoHexString(int i)Returns a hes string for i.
static StringtoOctalString(int i)Returns a octal string for i.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.