VOOZH about

URL: https://www.geeksforgeeks.org/java/shorts-class-guava-java/

⇱ Shorts Class | Guava | Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Shorts Class | Guava | Java

Last Updated : 21 Nov, 2019
Shorts is a utility class for primitive type short. It provides Static utility methods pertaining to short primitives, that are not already found in either Short or Arrays. Declaration :
@GwtCompatible(emulated=true)
public final class Shorts
extends Object
Below table shows the Field summary for Guava Shorts Class : 👁 Image
Some of the methods provided by Guava Shorts Class are : 👁 Image
Exceptions :
  • checkedCast : IllegalArgumentException if value is greater than Short.MAX_VALUE or less than Short.MIN_VALUE
  • min : IllegalArgumentException if array is empty.
  • max : IllegalArgumentException if array is empty.
  • fromByteArray : IllegalArgumentException if bytes has fewer than 2 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 Shorts Class : 👁 Image
Below given are some examples showing the implementation of Guava Shorts Class methods : Example 1 : Output :
[3, 4, 5, 6, 7]
Example 2 : Output :
2
Example 3 : Output :
[3, 4, 5, 6, 7]
Example 4 : output :
false
true
Example 5 : Output :
3
Example 6 :
Output :
7
Comment
Article Tags:
Article Tags: