Guava Booleans类
Booleans是一个用于原始类型Boolean的实用类。
类声明
以下是 com.google.common.primitives.Booleans 类的声明:
方法
序号 | 方法与描述 |
---|---|
1 | static List |
2 | static int compare(boolean a, boolean b) 以标准方式比较两个指定的布尔值(false被认为小于true)。 |
3 | static boolean[] concat(boolean[]… arrays) 返回将每个提供的数组的值合并到一个单独的数组中。 |
4 | static boolean contains(boolean[] array, boolean target) 如果目标在数组中的任何位置作为元素存在,则返回true。 |
5 | static int countTrue(boolean… values) 返回为true的值的数量。 |
6 | static boolean[] ensureCapacity(boolean[] array, int minLength, int padding) 返回包含与数组相同值的数组,但其长度保证为指定的最小长度。 |
7 | static int hashCode(boolean value) 返回值的哈希码;等同于调用((Boolean)value).hashCode()的结果。 |
8 | static int indexOf(boolean[] array, boolean target) 返回值target在数组中第一次出现的索引。 |
9 | static int indexOf(boolean[] array, boolean[] target) 返回数组中指定目标第一次出现的起始位置,如果不存在则返回-1。 |
10 | static String join(String separator, boolean… array) 返回一个包含提供的布尔值的字符串,由分隔符分隔。 |
11 | static int lastIndexOf(boolean[] array, boolean target) 返回值target在数组中最后一次出现的索引。 |
12 | static Comparator <boolean[]> lexicographicalComparator() 返回一个按字典顺序比较两个布尔数组的比较器。 |
13 | static boolean[] toArray(Collection |
继承方法
这个类从以下类继承方法:
- java.lang.Object
Booleans类示例
使用您选择的任何编辑器创建以下Java程序,例如在C:/> Guava目录中:
GuavaTester.java
验证结果
使用 javac 编译器编译类,如下所示−
现在运行GuavaTester来查看结果。
查看结果。