char primitives, that are not already found in
either Character or Arrays.
All the operations in this class treat char values strictly numerically; they are
neither Unicode-aware nor locale-dependent.
See the Guava User Guide article on primitive utilities.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BYTES
The number of bytes required to represent a primitive |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static List | Returns: a list view of the arraythe array to back the list backingArray)Returns a fixed-size list backed by the specified array, similar to |
| public static char | Returns: thechar value that equals valueany value in the range of the value)char typeReturns the |
| public static int | Returns: a negative value ifa is less than b; a positive value if a is
greater than b; or zero if they are equalthe first a, char char to comparethe second b)char to compareCompares the two specified |
| public static char[] | Returns: a single array containing all the values from the source arrays, in orderzero or more arrays)char arraysReturns the values from each provided array combined into a single array. |
| public static char | constrainToRange(char
the value, char char value to constrainthe lower bound (inclusive) of the range to constrain min, char value tothe upper bound (inclusive) of the range to constrain max)value toReturns the value nearest to |
| public static boolean | Returns: true if array[i] == target for some value of ian array of array, char char values, possibly emptya primitive target)char valueReturns |
| public static char[] | Returns: an array containing the values ofarray, with guaranteed minimum length minLengththe source array array, int the minimum length the returned array must guarantee minLength, int an extra amount to "grow" the array by if growth is necessary padding)Returns an array containing the same values as |
| public static char | fromByteArray(byte[] bytes)
Returns the |
| public static char | fromBytes(byte b1, byte b2)
Returns the |
| public static int | Returns: a hash code for the valuea primitive value)char valueReturns a hash code for |
| public static int | Returns: the least indexi for which array[i] == target, or -1 if no
such index exists.an array of array, char char values, possibly emptya primitive target)char valueReturns the index of the first appearance of the value |
| private static int | |
| public static int | indexOf(char[]
the array to search for the sequence array, char[] targetthe array to search for as a sub-sequence of target)arrayReturns the start position of the first occurrence of the specified |
| public static String | |
| public static int | Returns: the greatest indexi for which array[i] == target, or -1 if no
such index exists.an array of array, char char values, possibly emptya primitive target)char valueReturns the index of the last appearance of the value |
| private static int | |
| public static Comparator | lexicographicalComparator()
Returns a comparator that compares two |
| public static char | Returns: the value present inarray that is greater than or equal to every other value
in the arraya nonempty array of array)char valuesReturns the greatest value present in |
| public static char | Returns: the value present inarray that is less than or equal to every other value in
the arraya nonempty array of array)char valuesReturns the least value present in |
| public static void | |
| public static void | reverse(char[] array, int fromIndex, int toIndex)
Reverses the elements of |
| public static void | rotate(char[] array, int distance)
Performs a right rotation of |
| public static void | rotate(char[] array, int distance, int fromIndex, int toIndex)
Performs a right rotation of |
| public static char | Returns: the same value cast tochar if it is in the range of the char type,
Character#MAX_VALUE if it is too large, or Character#MIN_VALUE if it is too
smallany value)long valueReturns the |
| public static void | |
| public static void | sortDescending(char[] array, int fromIndex, int toIndex)
Sorts the elements of |
| public static char[] | Returns: an array containing the same values ascollection, in the same order, converted
to primitivesa collection of collection)Character objectsCopies a collection of |
| public static byte[] | toByteArray(char value)
Returns a big-endian representation of |
| BYTES | back to summary |
|---|---|
| public static final int BYTES The number of bytes required to represent a primitive Java 8+ users: use | |
| Chars | back to summary |
|---|---|
| private Chars() | |
| asList | back to summary |
|---|---|
| public static List Returns a fixed-size list backed by the specified array, similar to The returned list maintains the values, but not the identities, of The returned list is serializable. | |
| checkedCast | back to summary |
|---|---|
| public static char checkedCast(long value) Returns the
| |
| compare | back to summary |
|---|---|
| public static int compare(char a, char b) Compares the two specified Java 7+ users: this method should be treated as deprecated; use the equivalent
| |
| concat | back to summary |
|---|---|
| public static char[] concat(char[]... arrays) Returns the values from each provided array combined into a single array. For example,
| |
| constrainToRange | back to summary |
|---|---|
| public static char constrainToRange(char value, char min, char max) Returns the value nearest to If
| |
| contains | back to summary |
|---|---|
| public static boolean contains(char[] array, char target) Returns
| |
| ensureCapacity | back to summary |
|---|---|
| public static char[] ensureCapacity(char[] array, int minLength, int padding) Returns an array containing the same values as
| |
| fromByteArray | back to summary |
|---|---|
| public static char fromByteArray(byte[] bytes) Returns the Arguably, it's preferable to use
| |
| fromBytes | back to summary |
|---|---|
| public static char fromBytes(byte b1, byte b2) Returns the
| |
| hashCode | back to summary |
|---|---|
| public static int hashCode(char value) Returns a hash code for Java 8+ users: use
| |
| indexOf | back to summary |
|---|---|
| public static int indexOf(char[] array, char target) Returns the index of the first appearance of the value
| |
| indexOf | back to summary |
|---|---|
| private static int indexOf(char[] array, char target, int start, int end) | |
| indexOf | back to summary |
|---|---|
| public static int indexOf(char[] array, char[] target) Returns the start position of the first occurrence of the specified More formally, returns the lowest index
| |
| join | back to summary |
|---|---|
| public static String join(String separator, char... array) Returns a string containing the supplied
| |
| lastIndexOf | back to summary |
|---|---|
| public static int lastIndexOf(char[] array, char target) Returns the index of the last appearance of the value
| |
| lastIndexOf | back to summary |
|---|---|
| private static int lastIndexOf(char[] array, char target, int start, int end) | |
| lexicographicalComparator | back to summary |
|---|---|
| public static Comparator Returns a comparator that compares two The returned comparator is inconsistent with
| |
| max | back to summary |
|---|---|
| public static char max(char... array) Returns the greatest value present in
| |
| min | back to summary |
|---|---|
| public static char min(char... array) Returns the least value present in
| |
| reverse | back to summary |
|---|---|
| public static void reverse(char[] array) Reverses the elements of
| |
| reverse | back to summary |
|---|---|
| public static void reverse(char[] array, int fromIndex, int toIndex) Reverses the elements of
| |
| rotate | back to summary |
|---|---|
| public static void rotate(char[] array, int distance) Performs a right rotation of The provided "distance" may be negative, which will rotate left.
| |
| rotate | back to summary |
|---|---|
| public static void rotate(char[] array, int distance, int fromIndex, int toIndex) Performs a right rotation of The provided "distance" may be negative, which will rotate left.
| |
| saturatedCast | back to summary |
|---|---|
| public static char saturatedCast(long value) Returns the
| |
| sortDescending | back to summary |
|---|---|
| public static void sortDescending(char[] array) Sorts the elements of
| |
| sortDescending | back to summary |
|---|---|
| public static void sortDescending(char[] array, int fromIndex, int toIndex) Sorts the elements of
| |
| toArray | back to summary |
|---|---|
| public static char[] toArray(Collection<Character> collection) Copies a collection of Elements are copied from the argument collection as if by
| |
| toByteArray | back to summary |
|---|---|
| public static byte[] toByteArray(char value) Returns a big-endian representation of If you need to convert and concatenate several values (possibly even of different types),
use a shared
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final char[] | |
| pack-priv final int | |
| private static final long | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | contains(Object
element whose presence in this list is to be tested target)Overrides java. Implements java. true if this list contains the specified element.
|
| public boolean | equals(Object
the object to be compared for equality with this list object)Overrides java. Implements java. |
| public Character | get(int
index of the element to return index)Implements abstract java. Implements java. |
| public int | hashCode()
Overrides java. Implements java. |
| public int | indexOf(Object
element to search for target)Overrides java. Implements java. |
| public boolean | isEmpty()
Overrides java. Implements java. true if this list contains no elements.
|
| public int | lastIndexOf(Object
element to search for target)Overrides java. Implements java. |
| public Character | set(int
index of the element to replace index, Character element to be stored at the specified position element)Overrides java. Implements java. |
| public int | size()
Implements abstract java. Implements java. |
| public List | subList(int
low endpoint (inclusive) of the subList fromIndex, int high endpoint (exclusive) of the subList toIndex)Overrides java. Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| pack-priv char[] | |
| public String | toString()
Overrides java. |
| array | back to summary |
|---|---|
| pack-priv final char[] array | |
| end | back to summary |
|---|---|
| pack-priv final int end | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| start | back to summary |
|---|---|
| pack-priv final int start | |
| CharArrayAsList | back to summary |
|---|---|
| pack-priv CharArrayAsList(char[] array) | |
| CharArrayAsList | back to summary |
|---|---|
| pack-priv CharArrayAsList(char[] array, int start, int end) | |
| contains | back to summary |
|---|---|
| public boolean contains(Object target) Overrides java. Implements java. Doc from java. Returns | |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| get | back to summary |
|---|---|
| public Character get(int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(Object target) Overrides java. Implements java. Doc from java. Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides java. Implements java. Doc from java. Returns
| |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(Object target) Overrides java. Implements java. Doc from java. Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the highest index
| |
| set | back to summary |
|---|---|
| public Character set(int index, Character element) Overrides java. Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| subList | back to summary |
|---|---|
| public List Overrides java. Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
| |
| toCharArray | back to summary |
|---|---|
| pack-priv char[] toCharArray() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of this collection. The string
representation consists of a list of the collection's elements in the
order they are returned by its iterator, enclosed in square brackets
( | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Chars. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(char[]
the first object to be compared. left, char[] the second object to be compared. right)Implements java. |
| public String | toString()
Overrides java. |
| public static Chars. | |
| public static Chars. |
| INSTANCE | back to summary |
|---|---|
| public static final Chars. | |
| LexicographicalComparator | back to summary |
|---|---|
| private LexicographicalComparator() | |
| compare | back to summary |
|---|---|
| public int compare(char[] left, char[] right) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static Chars. | |
| values | back to summary |
|---|---|
| public static Chars. | |