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

How to use
size
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.size (Showing top 20 results out of 77,517)

Refine searchRefine arrow

  • ArrayList.get
  • ArrayList.add
  • ArrayList.<init>
  • ArrayList.toArray
  • PrintStream.println
canonical example by Tabnine

private void usingArrayList() {
 ArrayList<String> list = new ArrayList<>(Arrays.asList("cat", "cow", "dog"));
 list.add("fish");
 int size = list.size(); // size = 4
 list.set(size - 1, "horse"); // replacing the last element to "horse"
 String removed = list.remove(1); // removed = "cow"
 String second = list.get(1); // second = "dog"
}
origin: apache/incubator-dubbo

/**
 * Adds a list/map reference.
 */
@Override
public int addRef(Object ref) {
  if (_refs == null)
    _refs = new ArrayList();
  _refs.add(ref);
  return _refs.size() - 1;
}
origin: ReactiveX/RxJava

@Override
public void add(int index, T element) {
  list.add(index, element);
  lazySet(list.size());
}
origin: stackoverflow.com

 // Substitute appropriate type.
ArrayList<...> a = new ArrayList<...>();

// Add elements to list.

// Generate an iterator. Start just after the last element.
ListIterator li = a.listIterator(a.size());

// Iterate in reverse.
while(li.hasPrevious()) {
 System.out.println(li.previous());
}
origin: stackoverflow.com

 public class SortedList<E> extends AbstractList<E> {

  private ArrayList<E> internalList = new ArrayList<E>();

  // Note that add(E e) in AbstractList is calling this one
  @Override 
  public void add(int position, E e) {
    internalList.add(e);
    Collections.sort(internalList, null);
  }

  @Override
  public E get(int i) {
    return internalList.get(i);
  }

  @Override
  public int size() {
    return internalList.size();
  }

}
origin: google/ExoPlayer

private List<Cue> getDisplayCues() {
 List<Cue> displayCues = new ArrayList<>();
 for (int i = 0; i < cueBuilders.size(); i++) {
  Cue cue = cueBuilders.get(i).build();
  if (cue != null) {
   displayCues.add(cue);
  }
 }
 return displayCues;
}
origin: google/guava

@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherListWithDifferentElements() {
 ArrayList<E> other = new ArrayList<>(getSampleElements());
 other.set(other.size() / 2, getSubjectGenerator().samples().e3());
 assertFalse(
   "A List should not equal another List containing different elements.",
   getList().equals(other));
}
origin: scouter-project/scouter

public void printCRUD() {
  do {
    System.out.print("type:" + sqlNode.type.toString() + "-->");
    for (int i = 0; i < sqlNode.tableList.size(); i++) {
      System.out.print(sqlNode.tableList.get(i) + " ");
    }
    System.out.println();
    sqlNode = sqlNode.nextNode;
  } while (sqlNode != null);
}
origin: stanfordnlp/CoreNLP

protected ArrayList<Integer> scanForPronouns(ArrayList<Pair<Integer, Integer>> nonQuoteRuns) {
 ArrayList<Integer> pronounList = new ArrayList<>();
 for(int run_index = 0; run_index < nonQuoteRuns.size(); run_index++)
  pronounList.addAll(scanForPronouns(nonQuoteRuns.get(run_index)));
 return pronounList;
}
origin: apache/flink

/**
 * Increases the result vector component at the specified position by the specified delta.
 */
private void updateResultVector(int position, int delta) {
  // inflate the vector to contain the given position
  while (this.resultVector.size() <= position) {
    this.resultVector.add(0);
  }
  // increment the component value
  final int component = this.resultVector.get(position);
  this.resultVector.set(position, component + delta);
}
origin: FudanNLP/fnlp

private void initBaseDist() {
  for (int i = 0; i < classCenter.size(); i++) {
    float base = getBaseDist(i);
    baseDistList.add(base);
  }
  System.out.println("Finish init base distance list");
}
origin: redisson/redisson

public CtField[] getFields() {
  ArrayList alist = new ArrayList();
  getFields(alist, this);
  return (CtField[])alist.toArray(new CtField[alist.size()]);
}
origin: libgdx/libgdx

  public void mouseDragged (MouseEvent event) {
    if (dragIndex == -1 || dragIndex == 0 || dragIndex == percentages.size() - 1) return;
    float percent = (event.getX() - gradientX) / (float)gradientWidth;
    percent = Math.max(percent, percentages.get(dragIndex - 1) + 0.01f);
    percent = Math.min(percent, percentages.get(dragIndex + 1) - 0.01f);
    percentages.set(dragIndex, percent);
    repaint();
  }
});
origin: stanfordnlp/CoreNLP

 public static void main(String [] argv) throws Exception {
  if (argv.length != 1) {
   log.info("Usage: java AceDomReader <APF file>");
   System.exit(1);
  }

  File f = new File(argv[0]);
  AceDocument doc = parseDocument(f);
  System.out.println("Processed ACE document:\n" + doc);
  ArrayList<ArrayList<AceRelationMention>> r = doc.getAllRelationMentions();
  System.out.println("size: " + r.size());
 }
}
origin: apache/flink

  @Override
  public void reduce(Iterable<Tuple2<Long, Long>> values, Collector<Tuple2<Long, Long[]>> out) {
    neighbors.clear();
    Long id = 0L;
    for (Tuple2<Long, Long> n : values) {
      id = n.f0;
      neighbors.add(n.f1);
    }
    out.collect(new Tuple2<Long, Long[]>(id, neighbors.toArray(new Long[neighbors.size()])));
  }
}
origin: redisson/redisson

/**
 * Returns exception chain starting from top up to root cause.
 */
public static Throwable[] getExceptionChain(Throwable throwable) {
  ArrayList<Throwable> list = new ArrayList<>();
  list.add(throwable);
  while ((throwable = throwable.getCause()) != null) {
    list.add(throwable);
  }
  Throwable[] result = new Throwable[list.size()];
  return list.toArray(result);
}
origin: ReactiveX/RxJava

@Test
public void testFirstGroupsCompleteAndParentSlowToThenEmitFinalGroupsWhichThenSubscribesOnAndDelaysAndThenCompletes() throws InterruptedException {
  System.err.println("----------------------------------------------------------------------------------------------");
  final CountDownLatch first = new CountDownLatch(2); // there are two groups to first complete
  final ArrayList<String> results = new ArrayList<String>();
  Flowable.unsafeCreate(new Publisher<Integer>() {
  System.out.println("Results: " + results);
  assertEquals(6, results.size());
origin: ReactiveX/RxJava

@Test
public void testStart() {
  Observable<String> os = OBSERVABLE_OF_5_INTEGERS
      .zipWith(OBSERVABLE_OF_5_INTEGERS, new BiFunction<Integer, Integer, String>() {
        @Override
        public String apply(Integer a, Integer b) {
          return a + "-" + b;
        }
      });
  final ArrayList<String> list = new ArrayList<String>();
  os.subscribe(new Consumer<String>() {
    @Override
    public void accept(String s) {
      System.out.println(s);
      list.add(s);
    }
  });
  assertEquals(5, list.size());
  assertEquals("1-1", list.get(0));
  assertEquals("2-2", list.get(1));
  assertEquals("5-5", list.get(4));
}
origin: apache/incubator-dubbo

/**
 * Adds a list/map reference.
 */
@Override
public int addRef(Object ref) {
  if (_refs == null)
    _refs = new ArrayList();
  _refs.add(ref);
  return _refs.size() - 1;
}
origin: ReactiveX/RxJava

@Test
public void testStartEmptyObservables() {
  Observable<String> o = Observable.zip(Observable.<Integer> empty(), Observable.<String> empty(), new BiFunction<Integer, String, String>() {
    @Override
    public String apply(Integer t1, String t2) {
      return t1 + "-" + t2;
    }
  });
  final ArrayList<String> list = new ArrayList<String>();
  o.subscribe(new Consumer<String>() {
    @Override
    public void accept(String s) {
      System.out.println(s);
      list.add(s);
    }
  });
  assertEquals(0, list.size());
}
java.utilArrayListsize

Javadoc

The number of elements in this list.

Popular methods of ArrayList

  • <init>
  • add
  • get
    Returns the element at the specified position in this list.
  • toArray
    Returns an array containing all of the elements in this list in proper sequence (from first to last
  • addAll
    Adds the objects in the specified collection to this ArrayList.
  • remove
    Removes the first occurrence of the specified element from this list, if it is present. If the list
  • clear
    Removes all elements from this ArrayList, leaving it empty.
  • isEmpty
    Returns true if this list contains no elements.
  • iterator
    Returns an iterator over the elements in this list in proper sequence.The returned iterator is fail-
  • contains
    Searches this ArrayList for the specified object.
  • set
    Replaces the element at the specified position in this list with the specified element.
  • indexOf
    Returns the index of the first occurrence of the specified element in this list, or -1 if this list
  • set,
  • indexOf,
  • clone,
  • subList,
  • stream,
  • ensureCapacity,
  • trimToSize,
  • removeAll,
  • toString

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • CodeWhisperer alternatives
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