Tabnine Logo
List.size
Code IndexAdd Tabnine to your IDE (free)

How to use
size
method
in
java.util.List

Best Java code snippets using java.util.List.size (Showing top 20 results out of 347,274)

Refine searchRefine arrow

  • List.get
  • List.add
  • Assert.assertEquals
  • Test.<init>
  • List.toArray
  • List.isEmpty
  • Map.get
canonical example by Tabnine

private String[] makeArrayFromList(List<String> list, int maxSize) {
 if (maxSize < list.size()) {
  list = list.subList(0, maxSize);
 }
 return list.toArray(new String[0]);
}
origin: spring-projects/spring-framework

private Node getParent() {
  if (!this.elements.isEmpty()) {
    return this.elements.get(this.elements.size() - 1);
  }
  else {
    return this.node;
  }
}
origin: stackoverflow.com

 List<String> stockList = new ArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");

String[] stockArr = new String[stockList.size()];
stockArr = stockList.toArray(stockArr);

for(String s : stockArr)
  System.out.println(s);
origin: spring-projects/spring-framework

@Override
public CacheInvocationParameter[] getAllParameters(Object... values) {
  if (this.allParameterDetails.size() != values.length) {
    throw new IllegalStateException("Values mismatch, operation has " +
        this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)");
  }
  List<CacheInvocationParameter> result = new ArrayList<>();
  for (int i = 0; i < this.allParameterDetails.size(); i++) {
    result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i]));
  }
  return result.toArray(new CacheInvocationParameter[0]);
}
origin: ReactiveX/RxJava

@Test
public void testSkipAndCountGaplessWindows() {
  Observable<String> subject = Observable.just("one", "two", "three", "four", "five");
  Observable<Observable<String>> windowed = subject.window(3, 3);
  List<List<String>> windows = toLists(windowed);
  assertEquals(2, windows.size());
  assertEquals(list("one", "two", "three"), windows.get(0));
  assertEquals(list("four", "five"), windows.get(1));
}
origin: square/okhttp

public static List<String> alpnProtocolNames(List<Protocol> protocols) {
 List<String> names = new ArrayList<>(protocols.size());
 for (int i = 0, size = protocols.size(); i < size; i++) {
  Protocol protocol = protocols.get(i);
  if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN.
  names.add(protocol.toString());
 }
 return names;
}
origin: square/okhttp

static String extractStatusLine(Map<String, List<String>> javaResponseHeaders)
  throws ProtocolException {
 List<String> values = javaResponseHeaders.get(null);
 if (values == null || values.size() == 0) {
  // The status line is missing. This suggests a badly behaving cache.
  throw new ProtocolException(
    "CacheResponse is missing a \'null\' header containing the status line. Headers="
      + javaResponseHeaders);
 }
 return values.get(0);
}
origin: alibaba/druid

public static String getVerticalFormattedOutput(List<Map<String, Object>> content, String[] titleFields) {
  List<String[]> printContents = new ArrayList<String[]>();
  int maxCol = content.size() > MAX_COL ? MAX_COL : content.size();
  for (String titleField : titleFields) {
    String[] row = new String[maxCol + 1];
    row[0] = titleField;
    for (int j = 0; j < maxCol; j++) {
      Map<String, Object> sqlStat = content.get(j);
      Object value = sqlStat.get(titleField);
      row[j + 1] = handleAndConvert(value, titleField);
    }
    printContents.add(row);
  }
  return TableFormatter.format(printContents);
}
origin: spring-projects/spring-framework

private <T extends ObjectError> List<T> escapeObjectErrors(List<T> source) {
  List<T> escaped = new ArrayList<>(source.size());
  for (T objectError : source) {
    escaped.add(escapeObjectError(objectError));
  }
  return escaped;
}
origin: spring-projects/spring-framework

@Test
public void sortByQualityUnrelated() {
  MediaType audioBasic = new MediaType("audio", "basic");
  MediaType audioWave = new MediaType("audio", "wave");
  MediaType textHtml = new MediaType("text", "html");
  List<MediaType> expected = new ArrayList<>();
  expected.add(textHtml);
  expected.add(audioBasic);
  expected.add(audioWave);
  List<MediaType> result = new ArrayList<>(expected);
  MediaType.sortBySpecificity(result);
  for (int i = 0; i < result.size(); i++) {
    assertSame("Invalid media type at " + i, expected.get(i), result.get(i));
  }
}
origin: spring-projects/spring-framework

/**
 * Return all configured {@link MappedInterceptor MappedInterceptors} as an array.
 * @return the array of {@link MappedInterceptor MappedInterceptors}, or {@code null} if none
 */
@Nullable
protected final MappedInterceptor[] getMappedInterceptors() {
  List<MappedInterceptor> mappedInterceptors = new ArrayList<>(this.adaptedInterceptors.size());
  for (HandlerInterceptor interceptor : this.adaptedInterceptors) {
    if (interceptor instanceof MappedInterceptor) {
      mappedInterceptors.add((MappedInterceptor) interceptor);
    }
  }
  return (!mappedInterceptors.isEmpty() ? mappedInterceptors.toArray(new MappedInterceptor[0]) : null);
}
origin: spring-projects/spring-framework

private static Profiles merge(String expression, List<Profiles> elements, @Nullable Operator operator) {
  assertWellFormed(expression, !elements.isEmpty());
  if (elements.size() == 1) {
    return elements.get(0);
  }
  Profiles[] profiles = elements.toArray(new Profiles[0]);
  return (operator == Operator.AND ? and(profiles) : or(profiles));
}
origin: google/guava

 private static <T> List<T> shuffledCopy(List<T> in, Random random) {
  List<T> mutable = newArrayList(in);
  List<T> out = newArrayList();
  while (!mutable.isEmpty()) {
   out.add(mutable.remove(random.nextInt(mutable.size())));
  }
  return out;
 }
}
origin: spring-projects/spring-framework

@Ignore  // passes under Eclipse, fails under Ant
@Test
public void classpathStarWithPatternOnFileSystem() throws IOException {
  Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/sup*/*.class");
  // Have to exclude Clover-generated class files here,
  // as we might be running as part of a Clover test run.
  List<Resource> noCloverResources = new ArrayList<>();
  for (Resource resource : resources) {
    if (!resource.getFilename().contains("$__CLOVER_")) {
      noCloverResources.add(resource);
    }
  }
  resources = noCloverResources.toArray(new Resource[noCloverResources.size()]);
  assertProtocolAndFilenames(resources, "file",
      StringUtils.concatenateStringArrays(CLASSES_IN_CORE_IO_SUPPORT, TEST_CLASSES_IN_CORE_IO_SUPPORT));
}
origin: ReactiveX/RxJava

@Test(timeout = 1000)
public void testCompositeExceptionFromTwoDuplicateComposites() {
  List<Throwable> exs = new ArrayList<Throwable>();
  exs.add(getNewCompositeExceptionWithEx123());
  exs.add(getNewCompositeExceptionWithEx123());
  CompositeException cex = new CompositeException(exs);
  System.err.println("----------------------------- print composite stacktrace");
  cex.printStackTrace();
  assertEquals(3, cex.getExceptions().size());
  assertNoCircularReferences(cex);
  assertNotNull(getRootCause(cex));
  System.err.println("----------------------------- print cause stacktrace");
  cex.getCause().printStackTrace();
}
origin: square/okhttp

@Override public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
 Handshake handshake = handshake();
 if (handshake == null) return null;
 List<Certificate> result = handshake.peerCertificates();
 return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null;
}
origin: google/guava

 @Override
 ImmutableSet<?> create(List<?> list) {
  Object o1 = list.get(0);
  Object o2 = list.get(1);
  Object o3 = list.get(2);
  Object o4 = list.get(3);
  Object o5 = list.get(4);
  Object o6 = list.get(5);
  Object[] rest = list.subList(6, list.size()).toArray();
  return ImmutableSet.of(o1, o2, o3, o4, o5, o6, rest);
 }
},
origin: ReactiveX/RxJava

@Test
public void merge10AsyncStreamOf1000() {
  TestObserver<Integer> to = new TestObserver<Integer>();
  mergeNAsyncStreamsOfN(10, 1000).subscribe(to);
  to.awaitTerminalEvent();
  to.assertNoErrors();
  assertEquals(10000, to.values().size());
}
origin: iluwatar/java-design-patterns

/**
 * Handle request
 */
public synchronized void serverRequest(Request request) {
 if (lastServedId >= SERVERS.size()) {
  lastServedId = 0;
 }
 Server server = SERVERS.get(lastServedId++);
 server.serve(request);
}

origin: google/guava

static <E> List<List<E>> create(List<? extends List<? extends E>> lists) {
 ImmutableList.Builder<List<E>> axesBuilder = new ImmutableList.Builder<>(lists.size());
 for (List<? extends E> list : lists) {
  List<E> copy = ImmutableList.copyOf(list);
  if (copy.isEmpty()) {
   return ImmutableList.of();
  }
  axesBuilder.add(copy);
 }
 return new CartesianList<E>(axesBuilder.build());
}
java.utilListsize

Javadoc

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Popular methods of List

  • add
  • get
    Returns the element at the specified location in this List.
  • isEmpty
    Returns whether this List contains no elements.
  • addAll
  • toArray
    Returns an array containing all elements contained in this List. If the specified array is large eno
  • contains
    Tests whether this List contains the specified object.
  • remove
    Removes the first occurrence of the specified object from this List.
  • iterator
    Returns an iterator on the elements of this List. The elements are iterated in the same order as the
  • clear
  • stream
  • forEach
  • set
    Replaces the element at the specified position in this list with the specified element (optional ope
  • forEach,
  • set,
  • subList,
  • indexOf,
  • equals,
  • hashCode,
  • removeAll,
  • listIterator,
  • sort

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • getApplicationContext (Context)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now