Home

intValue

intValue is a method name used in Java and other object-oriented environments to obtain a primitive int from a numeric object. In Java, intValue is defined in the abstract Number class and is overridden by concrete numeric wrappers such as Integer, Long, Float, Double, Short, and Byte, as well as by other Number implementations.

In Java, intValue returns the value of the object converted to a primitive int. For wrappers like

Usage considerations include null handling and potential loss of precision. Calling intValue on a null reference

Related methods in Java include longValue, shortValue, byteValue, floatValue, and doubleValue, all provided by Number and

Integer,
this
is
a
direct
unwrapping
of
the
contained
int.
For
other
wrappers,
floating-point
values
are
typically
truncated
to
remove
the
fractional
part,
and
larger
values
may
be
reduced
to
fit
into
32
bits.
Conversions
from
BigInteger
or
BigDecimal
may
lose
information
if
the
value
lies
outside
the
range
representable
by
an
int.
In
such
cases
the
operation
does
not
throw
an
exception;
it
simply
discards
the
excess
bits
or
fractional
portion.
results
in
a
NullPointerException,
as
with
other
method
calls
on
null.
This
method
is
useful
when
code
holds
a
Number
reference
and
needs
a
primitive
int
for
API
calls
that
require
int
parameters
or
for
arithmetic,
but
developers
should
be
aware
of
possible
truncation
or
overflow.
implemented
by
numeric
wrappers
and
custom
Number
subclasses.
Some
languages
offer
similar
functionality
under
different
names;
in
Java,
intValue
remains
a
standard
way
to
extract
an
int
from
a
generic
numeric
object.