TGViewer
Java Programming Java Programming @java_programming_notes · 33.2K subscribers
Post #1169 5.07K
18 Most common used Java List methods

1. add(E element) - Adds the specified element to the end of the list.
2. addAll(Collection<? extends E> c) - Adds all elements of the specified collection to the end of the list.
3. remove(Object o) - Removes the first occurrence of the specified element from the list.
4. remove(int index) - Removes the element at the specified position in the list.
5. get(int index) - Returns the element at the specified position in the list.
6. set(int index, E element) - Replaces the element at the specified position in the list with the specified element.
7. indexOf(Object o) - Returns the index of the first occurrence of the specified element in the list.
8. contains(Object o) - Returns true if the list contains the specified element.
9. size() - Returns the number of elements in the list.
10. isEmpty() - Returns true if the list contains no elements.
11. clear() - Removes all elements from the list.
12. toArray() - Returns an array containing all the elements in the list.
13. subList(int fromIndex, int toIndex) - Returns a view of the portion of the list between the specified fromIndex, inclusive, and toIndex, exclusive.
14. addAll(int index, Collection<? extends E> c) - Inserts all elements of the specified collection into the list, starting at the specified position.
15. iterator() - Returns an iterator over the elements in the list.
16. sort(Comparator<? super E> c) - Sorts the elements of the list according to the specified comparator.
17. replaceAll(UnaryOperator<E> operator) - Replaces each element of the list with the result of applying the given operator.
18. forEach(Consumer<? super E> action) - Performs the given action for each element of the list until all elements have been processed or the action throws an exception.
  • ❤ 11
  • 👍 1
More from @java_programming_notes
  1. Sep 23, 2026Important LLM Terms 🔹 Transformer Architecture 🔹 Attention Mechanism 🔹 Pre-training 🔹…
  2. Sep 19, 2026Java projects with tutorial 🚀 Supermarket Management: https://youtube.com/playlist?list=P…
  3. Sep 15, 2026Q5. Why should files be closed? 👉 To release resources and ensure pending data is properl…
  4. Sep 15, 2026import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; clas…
  5. Sep 15, 2026📁 Java File Handling (Important ⭐) File Handling allows Java programs to create, read, wr…
  6. Sep 14, 2026Best YouTube Playlists to learn Programming 👇 1/ Python: https://www.youtube.com/playlist…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →