Java Integer Tutorial, Reference and Example

PreviousNext

Description

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

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.

Fields

Name
Description
BYTES
get number of bytes used to represent an int value in two's complement binary form
MAX_VALUE
get the maximum value an int can have.
MIN_VALUE
get the minimum value an int can have
SIZE
get number of bits used to represent an int value in two's complement binary form.
TYPE
get Class instance representing the primitive type int

Constructors

Constructors
public Integer(int value)
Java create Integer from int primitive value
public Integer(String s) throws NumberFormatException
Java create Integer from String

Methods

Return
Description
int

bitCount(int i)
get the number of one-bits in the two's complement binary representation of the specified int value
byte

byteValue()
convert the value of this Integer as a byte
int

compare(int x, int y)
Compares two int values numerically.
int

compareTo(Integer another_Integer)
Compares two Integer objects numerically.
int

compareUnsigned(int x, int y)
Compares two int values numerically treating the values as unsigned.
Integer

decode(String nm) throws NumberFormatException
Decodes a String into an Integer
Optional<Integer>

describeConstable()
get Optional containing the nominal descriptor for this instance
int

divideUnsigned(int dividend, int divisor)
get unsigned quotient of dividing the first int by the second integer
double

doubleValue()
convert the value of this Integer as a double
boolean

equals(Object obj)
Compares this integer to the specified object.
float

floatValue()
convert the value of this Integer as a float after a widening primitive conversion.
Integer

getInteger(String nm)
get the integer value of the system property with the specified name.
Integer

getInteger(String nm, int val)
get the integer value of the system property with the specified name with default value
Integer

getInteger(String nm, Integer val)
get integer value of the system property with the specified name and default value
int

hashCode()
Returns a hash code for this Integer
int

hashCode(int value)
get the hash code for an int value; compatible with Integer
int

highestOneBit(int i)
get int value in single one-bit from the left most highest one-bit
int

intValue()
convert this Integer to int
long

longValue()
convert Integer to long after a widening primitive conversion
int

lowestOneBit(int i)
get a single bit from lowest-order right most one-bit from int
int

max(int a, int b)
get the greater of two int values
int

min(int a, int b)
get the smaller of two int values
int

numberOfLeadingZeros(int i)
get the number of zero bits preceding the highest-order one-bit
int

numberOfTrailingZeros(int i)
get the number of zero bits following the lowest-order one-bit
int

parseInt(String s, int radix) throws NumberFormatException
Parses the string as a signed integer by the radix
int

parseInt(CharSequence s, int begin_Index, int end_Index, int radix)
Parses string as a signed int by radix with offset
int

parseInt(String s) throws NumberFormatException
Parses the string argument as a signed decimal integer
int

parseUnsignedInt(String s, int radix) throws NumberFormatException
Parses the string as an unsigned integer by radix.
int

parseUnsignedInt(CharSequence s, int begin_Index, int end_Index, int radix)
Parses string as an unsigned int in by radix with offset
int

parseUnsignedInt(String s) throws NumberFormatException
Parses the string argument as an unsigned decimal integer.
int

remainderUnsigned(int dividend, int divisor)
get the unsigned remainder by dividing two integers
Integer

resolveConstantDesc(MethodHandles.Lookup lookup)
Resolves integer as a ConstantDesc
int

reverse(int i)
reverse the order of the bits in int value
int

reverseBytes(int i)
reverse the order of the bytes in the int value
int

rotateLeft(int i, int distance)
rotate int value left by the specified number of bits
int

rotateRight(int i, int distance)
rotate the int value right by the specified number of bits
short

shortValue()
convert Integer as a short after a narrowing primitive conversion
int

signum(int i)
get the sign for int value
int

sum(int a, int b)
Adds two integers together as per the + operator
String

toBinaryString(int i)
convert integer to binary in base 2
String

toHexString(int i)
convert integer to hexadecimal integer in base 16.
String

toOctalString(int i)
convert integer to unsigned integer in base 8
String

toString(int i, int radix)
convert int by radix
String

toString(int i)
convert integer to a String object in static way
String

toString()
convert integer to a String object
long

toUnsignedLong(int x)
Converts integer to long by an unsigned conversion
String

toUnsignedString(int i, int radix)
convert int to unsigned integer value by radix
String

toUnsignedString(int i)
Returns a string representation of the argument as an unsigned decimal value
Integer

valueOf(String s, int radix) throws NumberFormatException
parse string to Integer by radix
Integer

valueOf(String s) throws NumberFormatException
convert String to an Integer
Integer

valueOf(int i)
convert int primitive to Integer object

Example

PreviousNext

Related