code: public static int computeNewCapacity(int length, int requiredCapacity, int nextCapacityHint) {
          if (requiredCapacity < length) {
              return length;
          }
  
          int newCapacity = (length * 3) / 2 + 1;
  
          if (newCapacity < nextCapacityHint) {
              newCapacity = nextCapacityHint;
          }
  
          if (newCapacity < requiredCapacity) {
              newCapacity = requiredCapacity;
          }
  
          return newCapacity;
      }
docs: Computes the size of an array that is required to hold {@code requiredCapacity} number of elements.
  <p>
  This method first tries to increase the size of the array by a factor of 1.5 to prevent a sequence of successive
  increases by 1. It then evaluates the {@code nextCapacityHint} parameter as well as the {@code requiredCapacity}
  parameter to determine the next size.
  
  @param length
  the current length of the array
  @param requiredCapacity
  the immediately required capacity
  @param nextCapacityHint
  a hint for future capacity requirements that may not be required as of now
  
  @return the size of an array that is guaranteed to hold {@code requiredCapacity} number of elements.