toInteger

Returns this integer as an Integer.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val value: Integer = Integer.fromLong(42)
val nonNegativeInteger: NonNegativeInteger =
NonNegativeInteger.fromInteger(value)
val result: Integer = nonNegativeInteger.toInteger()
check(result == value)

Calling from Java

Here's an example of calling this function from Java code:

final Integer value = Integer.fromLong(42);
final NonNegativeInteger nonNegativeInteger =
NonNegativeInteger.fromInteger(value);
final Integer result = nonNegativeInteger.toInteger();
final boolean check = result.equals(value);
if (!check) throw new IllegalStateException("Check failed.");