code: public static <T> void addAll(Collection<? super T> collection, Collection<? extends T> toAdd)
      {
          if (collection == null || toAdd == null)
          {
              return;
          }
          if (toAdd instanceof RandomAccess)
          {
              List<? extends T> randomAccess = (List<? extends T>) toAdd;
              for (int i = 0, size = randomAccess.size(); i < size; i++)
              {
                  T element = randomAccess.get(i);
                  collection.add(element);
              }
          }
          else
          {
              collection.addAll(toAdd);
          }
      }
docs: Same as {@link Collection#addAll(Collection)} but in case of RandomAccess iterates over indices