from
Creates an Integer from the specified number.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
// Given
val number = 9223372036854775807
// When
val result: Integer = Integer.from(number)
// Then
check("$result" == "$number")Content copied to clipboard
Calling from Java
Here's an example of calling this function from Java code:
// Given
final long number = 9223372036854775807L;
// When
final Integer result = Integer.from(number);
// Then
final String resultAsString = result.toString();
final String expected = String.valueOf(number);
final boolean check = resultAsString.equals(expected);
if (!check) throw new IllegalStateException("Check failed.");Content copied to clipboard