🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
The ArrayDeque class in Java is a resizable array implementation of the Deque interface. It provides a way to use a double-ended queue, allowing elements to be added or removed from both ends efficiently. This class is a part of the java.util package and is known for its flexibility and performance benefits compared to other collection classes.
This guide covers various methods available in the ArrayDeque class. Each method is described in simple terms to help beginners understand how to use them. These methods enable you to perform common operations such as adding, removing, and inspecting elements in the deque.
For more detailed information, please refer to the official Java SE Documentation.
Java ArrayDeque Methods
The table below contains various methods of the Java ArrayDeque class, each with a link to a detailed explanation, examples, and real-world uses. Click on the method names to learn more about how to use them effectively in your applications.
| Method | Description |
|---|---|
| add() | Adds the specified element to the end of this deque. |
| addAll() | Adds all of the elements in the specified collection to the end of this deque. |
| addFirst() | Inserts the specified element at the front of this deque. |
| addLast() | Inserts the specified element at the end of this deque. |
| clear() | Removes all of the elements from this deque. |
| clone() | Returns a shallow copy of this deque. |
| contains() | Returns true if this deque contains the specified element. |
| descendingIterator() | Returns an iterator over the elements in this deque in reverse order. |
| element() | Retrieves, but does not remove, the head of this deque. |
| forEach() | Performs the given action for each element of the deque until all elements have been processed or the action throws an exception. |
| getFirst() | Retrieves, but does not remove, the first element of this deque. |
| getLast() | Retrieves, but does not remove, the last element of this deque. |
| isEmpty() | Returns true if this deque contains no elements. |
| offer() | Adds the specified element as the tail (last element) of this deque. |
| offerFirst() | Inserts the specified element at the front of this deque. |
| iterator() | Returns an iterator over the elements in this deque in proper sequence. |
| offerLast() | Inserts the specified element at the end of this deque. |
| peek() | Retrieves, but does not remove, the head of this deque, or returns null if this deque is empty. |
| peekFirst() | Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty. |
| peekLast() | Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty. |
| poll() | Retrieves and removes the head of this deque, or returns null if this deque is empty. |
| pollFirst() | Retrieves and removes the first element of this deque, or returns null if this deque is empty. |
| pollLast() | Retrieves and removes the last element of this deque, or returns null if this deque is empty. |
| pop() | Pops an element from the stack represented by this deque. |
| push() | Pushes an element onto the stack represented by this deque. |
| remove() | Removes the first occurrence of the specified element from this deque. |
| removeAll() | Removes all of this deque's elements that are also contained in the specified collection. |
| removeFirst() | Removes the first element of this deque. |
| removeFirstOccurrence() | Removes the first occurrence of the specified element in this deque. |
| removeIf() | Removes all of the elements of this deque that satisfy the given predicate. |
| removeLast() | Removes the last element of this deque. |
| removeLastOccurrence() | Removes the last occurrence of the specified element in this deque. |
| retainAll() | Retains only the elements in this deque that are contained in the specified collection. |
| size() | Returns the number of elements in this deque. |
| spliterator() | Returns a late-binding and fail-fast Spliterator over the elements in this deque. |
| toArray() | Returns an array containing all of the elements in this deque. |
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment