HashSet in java

The HashSet in java is most important part of the Java Collection Framework. The HashSet class implements the Set interface and extends the AbstractSet class. It also implements the Cloneable and Serializable interface. You can read it with an example from here.1. What is HashSet in Java?2. Important points HashSet in java?3. Creation of HashSet in java?4. HashSet Implementation in java?5. … Read more

descendingIterator() method

descendingIterator() method: The Descending Iterator in Java method of LinkedList class employs to return an iterator over the elements in this LinkedList in reverse sequential order. The descendingIterator returns an iterator with elements and these elements will be returned in order from last to first. It returns the object of the Iterator. Output: List from Name = … Read more

contains(Object obj) method

contains(Object obj) method: This object obj method uses to check the given element is present in LinkedList or not. It returns only a boolean value. If the given element exists in LinkedList, then it returns true otherwise false. Where, Object represents the type of class in LinkedList.obj is the element which you want to check … Read more

lastIndexOf(Object o) method

lastIndexOf(Object o): This lastindexof Object-o method utilizes to get the last index of a specified element. It returns the index value of the last occurrence of the element if LinkedList. It returns the int value. If the element doesn’t present in LinkedList it will return -1. Where, Object represents the type of elements in LinkedList.o, … Read more

trimToSize() method

trimToSize(): This trimtosize in Java method is used to trim the capacity of the instance of the ArrayList to the list’s current size. It doesn’t return anything, So its return type is void. Output: RAVIJAVAGOALSITE

set(int index, E element) method

set(int index, E element): This int index e element method uses to replace the element at the specified position in LinkedList with the specified element. Its returns the element after replacement. Where, E represents the type of elements in LinkedList.index, index of the element to return.throw, IndexOutOfBoundsException if index is invalid. Output: JAVASITERAVI

pollLast() method

pollLast(): This polllast method in java is used to removes and return the last element from LinkedList. Its return type is E. It Retrieves the element and also removes it from LinkedList. Where, E represents the type of elements in LinkedList.return null, if this LinkedList is empty. Output: Element present at first position is = … Read more

pollFirst() method

pollFirst(): This pollfirst Java method is employed to removes and returns the first element from LinkedList. Its return type is E element. It Retrieve the element and also removes it from the LinkedList. Where, E represents the type of elements in LinkedList.return null, if this LinkedList is empty. Output: Element present at first position is … Read more

poll method in java

poll(): This poll method in java is utilized to removes and return the first element from the LinkedList. Its return type is E. It Retrieves the element and also removes it from LinkedList. Where, E represents the type of elements in LinkedList.return null, if this LinkedList is empty. Output: Element present at first position is … Read more

peek() method

peek() method: The peek in Java method uses to get the first element from LinkedList. It just Retrieves the element but does not remove it. It returns the object. Where, E represents the type of elements in LinkedList.return null, if this LinkedList is empty. Output: Element present at first position is = JAVA