Article

Java Collection Framework

Topic: Coach Training and CertificationPublished November 6, 2017

Legacy signals

Legacy popularity: 560 legacy views

Collection framework represents group of classes and interfaces which can be used to represent a group of similar and non-similar type of object as a single entity and provides readymade methods support to store and manipulate collection objects. Collection API is present in java.util package. Collection’s subclasses are used to manage the group of elements without key and value pair. I -Interface c--class Methods of Collection interface public boolean add(Object ob): This method is used to add an object to collection object and List object. This method returns true when we add elements for Collection and List object because they allow duplicate elements. rnThis method returns false when we add elements for Set and SortedSet object if the new element is duplicate element. java/j2ee classes bangalore Set and SortedSet object does not allow duplicates. public boolean addAll(Collection c): This method is used to add all the elements of specified collection object at the end of current collection because insertion order is preserved in case of collection and List. This method returns true when we add elements for Collection and List object because they allow duplicate elements. rnThis method returns false when we add elements for Set and SortedSet object if the new element is duplicate element.Set and SortedSet object does not allow duplicates. public int size(): This methods returns the number of elements present in Collection object. public boolean isEmpty(): This method checks whether collection is empty or not. It returns true when Collection object is empty otherwise return false. rnpublic boolean contains(object ob): This method checks whether given object is present in collection or not. public boolean containsAll(Collection c): This method checks whether current collection contains all the elements of specified collection. ppublic boolean remove(Object ob): This method is used to remove first existence of specified object from collection. public boolean removeAll(Collection c): This method is used to remove similar elements of specified collection from current collection. public boolean retainAll(Collection c): This method is used to remove dissimilar elements of specified collection from current collection. public boolean clear(): This method is used to clear all the elements from collection. public object[] toArray(): This method is used to convert collection objects into array elements. rnpublic boolean equals(Object obj): This method is used to compare two collection objects. public Iterator iterator(): This method returns Iterator object that points before the first record. Iterator interface: Iterator interface provides the facility for traversing the collection objects in forward direction. Iterator interface has three methods. public boolean hasNext(): This method is used to check whether next element is available or not in the collection object. If next element present in the collection object then it returns true otherwise it returns false. public Object next(): This method is used to retrieve the next element in the collection object. public void remove(): This method is used to remove the current element from collection object. List List interface is available in java.util package and extends Collection interface. Best core java training in Bangalore It provides the following functionalities to sub classes. The elements are stored based on index. We can access any element directly based on specified index. List subclasses allows duplicates and null values. Reverse direction traversing is possible. We can insert elements either at the end of List object or at specific index. Commonly used methods of List interface: public object get(int index): This method is used to get element from the specified index. public object set(int index, Object element): This method is used to replace the existing element from List with given element from specified index. public void add(int index,Object element): This method is used to insert the element at specified index. public void addAll(int index,Collection c): This method is used to insert the elements of specified collection object to current object at specified index. public void remove(int index): This method is used to remove the element at specified index. public int indexOf(Object element): This method is used to return the first occurrence of specified element. rnpublic int lastIndexOf(Object element): This method is used to return the last occurrence of specified element. public ListIterator listIterator(): This method is used for accessing the data from List object either in forward or in backward. public ListIterator listIterator(int index): This method is used for accessing the data from List object that points to specified index. ListIterator interface: ListIterator interface provides the facility for traversing the List objects either in forward or in backward direction. ListIterator interface has following methods public boolean hasNext(): This method is used to check whether next element is available or not in the List object. If next element present in the List then it returns true otherwise it returns false. public Object next(): This method is used to retrieve the next element in the collection object. public boolean hasPrevious(): This method is used to check whether previous element is available or not in the List object. If previous element present in the List then it returns true otherwise it returns false. public Object previous(): This method is used to retrieve the previous element in the collection object.

Further reading

Further Reading

4 total

Article

How Coaching Turns Knowledge Into Change Walk into any bookstore or scroll through your favorite podcast feed, and you’ll see the same thing: endless tips, strategies, and “life hacks” promising transformation.rnWe devour them. We highlight paragraphs. We even try to practice what we’ve learned. But somehow, the big shifts never stick. Weeks later, the old patterns creep back in.rnSo why does it happen? Why do so many smart, motivated people keep getting stuck — eve

October 6, 2025

Article

grinding and cutting a variety of materials across numerous industries. Understanding their construction, types and safety precautions is mandatory for anyone working with these powerful tools. This article will explore the basics of abrasive wheels, offering insights into their components, maintenance and legal requirements to ensure both effective and safe usage. Exploring the Basics of Abrasive Wheels Abrasive wheels are critical tools in various industrial applications, f

March 6, 2025

Article

The internet we use daily, known as the surface web, represents only a fraction of the entire digital landscape. Beneath this visible layer lies the deep web and the dark web, where anonymity, privacy, and unrestricted information exchange thrive. Among the most well-known directories for accessing dark web content is the Uncensored Hidden Wiki . This article delves into the history, significance, risks, and access methods of the Uncensored Hidden Wiki, providing a comprehens

January 31, 2025

Article

If you're searching for exceptional piano classes near you, there are several excellent options in Toronto to consider. For those eager to learn the piano, finding a school or instructor that offers expert guidance, comprehensive lesson plans, and a supportive environment is key. Catering to both beginners and advanced players, many schools in the Toronto area provide tailored lessons to help students achieve their musical aspirations. What to Look for in Piano Lessons When

January 1, 2025