VOOZH about

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

⇱ Booleans Class | Guava | Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Booleans Class | Guava | Java

Last Updated : 1 Jun, 2022

Booleans is a utility class for primitive type Boolean. It provides Static utility methods pertaining to boolean primitives, that are not already found in either Boolean or Arrays. 

Declaration : 

@GwtCompatible(emulated=true)
public final class Booleans
extends Object

Below given are some methods provided by Guava Booleans Class : 👁 Image
 

Exceptions :

  • ensureCapacity : IllegalArgumentException if minLength or padding is negative.
  • toArray : NullPointerException if collection or any of its elements is null.

Following table shows some other methods provided by Guava Booleans Class : 👁 Image
 

Below given are some examples showing the implementation of Guava Booleans Class methods : 

Example 1 : 

Output :

[true, false, true, false, true]

Example 2 : 

Output :

[true, false, true, false, true]

Example 3 : 

Output :

[true, false, true, false, true]

Example 4 : 

output :

true
true

Example 5 : 

Output :

0

Example 6 : 

Output :

1
Comment
Article Tags:
Article Tags: