The int keyword
The int is a keyword in java that is used to define
32-bit signed integer (primitive type) values. Keywords
are basically reserved words which have specific meaning relevant to a compiler.
The keyword int in java programming language is also used to
declare an expression, method return value, or variable of integer type.
The java.lang.Integer class
in java programming language wraps a int type primitive value in an object. An
Integer type object includes only a single field whose type is int.
Wrapper class is used to convert the int primitive values into Integer type
objects. In addition to this Integer wrapper class also provides methods for
converting a int to String and vice versa as well as other constants and methods
that are useful to deal with int type.
Syntax: Here is the syntax that displays how to declare and define integer type values.
int
<variable-name> = <integer-value>; |
Example: Lets take an example that defines how to declare and define an integer type value
int
i = 34; |
Note: Here are some points which must be noted.
- The Integer class (wrapper class) defines MIN_VALUE and MAX_VALUE constants that represents the range of values of integer type.
- By default all integer literals are 32-bit unless the value follows by l or L. Character l or L indicates that the value should be treated as long.


