Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the length of an array list? [duplicate]

Tags:

java

arraylist

People also ask

How do you find duplicates in an ArrayList?

One of the most common ways to find duplicates is by using the brute force method, which compares each element of the array to every other element. This solution has the time complexity of O(n^2) and only exists for academic purposes.

How do you count duplicate elements in a list?

If you want to count duplicates for a given element then use the count() function. Use a counter() function or basics logic combination to find all duplicated elements in a list and count them in Python.


The size member function.

myList.size();

http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html


System.out.println(myList.size());

Since no elements are in the list

output => 0

myList.add("newString");  // use myList.add() to insert elements to the arraylist
System.out.println(myList.size());

Since one element is added to the list

output => 1