compareTo
Compares this integer with the other one for order. Returns a negative number, zero, or a positive number as this integer is less than, equal to, or greater than the other one.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
// Given
val x: Integer = Integer.from(Long.MIN_VALUE)
val y: Integer = Integer.from(Long.MAX_VALUE)
// When
val result: Boolean = x < y // or x.compareTo(y) < 0
// Then
check(result)Content copied to clipboard
Calling from Java
Here's an example of calling this function from Java code:
// Given
final Integer x = Integer.from(Long.MIN_VALUE);
final Integer y = Integer.from(Long.MAX_VALUE);
// When
final boolean result = x.compareTo(y) < 0;
// Then
if (!result) throw new IllegalStateException("Check failed.");Content copied to clipboard