Longs is a utility class for primitive type long. It provides
Static utility methods pertaining to long primitives, that are not already found in either Long or Arrays.
Declaration :
@GwtCompatible(emulated=true)
public final class Longs
extends Object
Below table shows the Field summary for Guava Longs Class :
👁 Image
Some of the methods provided by Guava Longs Class are :
👁 Image
Exceptions :
- min : IllegalArgumentException if array is empty.
- max : IllegalArgumentException if array is empty.
- fromByteArray : IllegalArgumentException if bytes has fewer than 8 elements.
- ensureCapacity : IllegalArgumentException if minLength or padding is negative.
- toArray : NullPointerException if collection or any of its elements is null.
Below table shows some other methods provided by Guava Longs Class :
👁 Image
Below given are some examples showing the implementation of methods of Guava Longs Class :
Example 1 :
Output :
[3, 4, 5, 6, 7]
Example 2 :
Output :
[3, 4, 5, 6, 7]
Example 3 :
Output :
[3, 4, 5, 6, 7]
Example 4 :
output :
true
false
Example 5 :
Output :
3
Example 6 :