public class ArrayUtil extends Object
| Constructor and Description |
|---|
ArrayUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
growSpace(int oldCapacity,
int minCapacity)
Given an old capacity of an array, generate the new capacity that is larger than or equal to minimum required capacity.
|
public static int growSpace(int oldCapacity,
int minCapacity)
MAX_ARRAY_SIZE, which is slightly smaller than Integer.MAX_VALUE to avoid
Out of Memory error. If the min capacity is smaller than old capacity, then old capacity will be simply returned.oldCapacity - old capacityminCapacity - minimum desired capacityIllegalArgumentException - if minimum required capacity is larger than MAX_ARRAY_SIZE, or minimum
required capacity is negative (likely caused by integer overflow)Copyright © 2012–2024. All rights reserved.