Integer class
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.
static int MAX_VALUE
- Maximum value an int can have.
static int MIN_VALUE
- Minimum value an int can have.
static int SIZE
- The number of bits used to represent an int value.
Constructor Summary
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
byte byteValue()
- Returns this Integer as a byte.
double doubleValue()
- Returns this Integer as a double.
float floatValue()
- Returns this Integer as a float.
int intValue()
- Returns this Integer as an int.
long longValue()
- Returns this Integer as a long.
short shortValue()
- Returns this Integer as a short.
Compare two integer values
int compareTo(Integer anotherInteger)
- Compares two Integer objects numerically.
boolean equals(Object obj)
- Compares this object to the specified object.
Decode a string and return an integer value
static Integer decode(String nm)
- Decodes a String into an Integer.
Convert string to integer
static int parseInt(String s)
- Parses the string argument as a signed decimal integer.
static int parseInt(String s, int radix)
- Parses the string argument in the radix.
static Integer valueOf(int i)
- Returns a Integer instance representing the int value.
static Integer valueOf(String s)
- Returns an Integer holding the value of the String.
static Integer valueOf(String s, int radix)
- Returns an Integer from String based on the radix.
Convert integer to string
String toString()
- Returns a String object representing this Integer's value.
static String toString(int i)
- Returns a String object representing the specified integer.
static String toString(int i, int radix)
- Returns a string representation of i in radix.
Reverse and rotate the integer in binary format
static int reverse(int i)
- Reversing the bits.
static int reverseBytes(int i)
- Reversing the bytes.
static int rotateLeft(int i, int distance)
- Rotating the bits by distance.
static int rotateRight(int i, int distance)
- Rotating the bits by distance.
Bit oriented operation
static int bitCount(int i)
- Count bits in the binary representation of the specified int value.
static int highestOneBit(int i)
- Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit.
static int lowestOneBit(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
static Integer getInteger(String nm)
- Get the system property.
static Integer getInteger(String nm, int val)
- Get the integer value of the system property with a default value.
static Integer getInteger(String nm, Integer val)
- Returns the integer value of the system property with a default value.
Get the leading and trailing zeros
static int numberOfLeadingZeros(int i)
- Returns the number of zero bits preceding the highest-order ("leftmost") one-bit.
static int numberOfTrailingZeros(int i)
- Returns the number of zero bits following the lowest-order ("rightmost") one-bit.
Get the sign
static int signum(int i)
- Returns the sign.
Convert integer to binary, hexdecimal and octal format
static String toBinaryString(int i)
- Return the binary string for i.
static String toHexString(int i)
- Returns a hes string for i.
static String toOctalString(int i)
- Returns a octal string for i.
Home
Java Book
Essential Classes
Java Book
Essential Classes
Integer:
- Integer class
- Max, min value of an integer type variable
- Create Integer using its constructors
- Return an integer value as byte, double, float, int, long and short
- Compare two integer values
- Decode a string and return an integer value
- Convert string to integer
- Convert integer to string
- Reverse and rotate the integer in binary format
- Bit oriented operation
- Return system property as integer
- Get the leading and trailing zeros
- Get the sign of an Integer
- Convert integer to binary, hexdecimal and octal format