Java Lab Documentation

Integer

Category:java.lang

The Integer class wraps the primitive type int in an object. The Integer class contains a variety of methods for converting int values or dealing with the int type in general.

Fields

TypeNameDescription
static final intMAX_VALUE

a constant that holds the maximum value that an int can have

static final int MIN_VALUE

a constant that holds the minimum value that an int can have

Method Details

Integer

Integer(int value)

Creates an Integer object that represents the specified int value.

Parameters

NameTypeRequired?Description
valueint

the value to be represented by the Integer object

Examples

Integer a = new Integer(23);

intValue

public int intValue()

Returns the value of the Integer object as an int.

Examples

Integer temp = new Integer(32);
int i = temp.intValue();

System.out.println("The integer value of i = " + i); 

Output:

The integer value of i = 32

parseInt

static int parseInt(String s)

Returns the String argument as an int.

Parameters

NameTypeRequired?Description
sString

a String representation of an integer

Examples

int temp = Integer.parseInt("10");
System.out.println("Integer Value of String 10: " + temp);

Output:

Integer Value of String 10: 10