Copies a collection of Character instances into a new array of primitive char values. Elements are copied from the argument collection as if by collection.toArray(). Calling this method is as thread-safe as calling that method. @param collection a collection of {@code Ch
(Collection<Character> collection)
| 435 | |
| 436 | |
| 437 | public static char[] toArray(Collection<Character> collection) { |
| 438 | if (collection instanceof CharArrayAsList) { |
| 439 | return ((CharArrayAsList) collection).toCharArray(); |
| 440 | } |
| 441 | Object[] boxedArray = collection.toArray(); |
| 442 | int len = boxedArray.length; |
| 443 | char[] array = new char[len]; |
| 444 | for (int i = 0; i < len; i++) { |
| 445 | // checkNotNull for GWT (do not optimize) |
| 446 | array[i] = (Character) checkNotNull(boxedArray[i]); |
| 447 | } |
| 448 | return array; |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Returns a fixed-size list backed by the specified array, similar to |
nothing calls this directly
no test coverage detected