{"id":22269,"date":"2020-02-12T12:33:58","date_gmt":"2020-02-12T12:33:58","guid":{"rendered":"https:\/\/cnsfly.com\/vytcdc\/?p=22269"},"modified":"2024-09-26T11:45:16","modified_gmt":"2024-09-26T11:45:16","slug":"collection-in-java","status":"publish","type":"post","link":"https:\/\/cnsfly.com\/vytcdc\/collection-in-java\/","title":{"rendered":"Collection in java"},"content":{"rendered":"<p>The java Collection is a framework that helps in storing and manipulating a group of objects,Collections are dynamic and they can grow their size dynamically at run time as the elements are added to it.<\/p>\n<p>The Collection is a root interface available in java.util.package.This is Implemented by three interfaces in\u00a0<a href=\"https:\/\/cnsfly.com\/vytcdc\/courses\/java-training-in-chennai\/\">Java Program<\/a>.<\/p>\n<ul>\n<li><strong>List<\/strong><\/li>\n<li><strong>Sets<\/strong><\/li>\n<li><strong>Queue<\/strong><\/li>\n<\/ul>\n<p>All the above three are data structures that allow to store and manipulate objects. And each one of them has slight differences.<\/p>\n<p><strong>List\u00a0<\/strong>\u2013List allows duplicate objects.<\/p>\n<p><strong>Sets<\/strong>\u00a0\u2013 Does not allow duplicate objects.<\/p>\n<p><strong>Queue<\/strong>\u2013It is a First in First out Data structure.<\/p>\n<p><strong>Implementation classes of Lists:<\/strong><\/p>\n<ul>\n<li><strong>ArrayList<\/strong><\/li>\n<li><strong>Linked List<\/strong><\/li>\n<li><strong>Vector<\/strong><\/li>\n<\/ul>\n<p><strong>ArrayList<\/strong><\/p>\n<ul>\n<li>It provides us dynamic arrays.<\/li>\n<li>It implements the List interface.<\/li>\n<li>The Arraylist class will allow duplicate elements.<\/li>\n<li>The Arraylist class maintains insertion order.<\/li>\n<\/ul>\n<p><strong>Linked List<\/strong><\/p>\n<ul>\n<li>It is a linear data structure.<\/li>\n<li>Linkedlist class will allow duplicate elements.<\/li>\n<li>Linkedlist class maintains insertion order<\/li>\n<\/ul>\n<p><strong>Vector<\/strong><\/p>\n<ul>\n<li>It is a synchronized class.<\/li>\n<li>It is a legacy class.<\/li>\n<li>It contains many legacy methods.<\/li>\n<\/ul>\n<p>The implementation class of sets is HashSet<\/p>\n<p><strong>HashSet<\/strong><\/p>\n<ul>\n<li>Hashset stores the elements by using a mechanism called hashing.<\/li>\n<li>Hashset does not allow duplicate elements.<\/li>\n<li>Hashset class is non synchronized.<\/li>\n<\/ul>\n<p>Hashset is implemented by another class called LinkedHashset.<\/p>\n<p><strong>LinkedHashset<\/strong><\/p>\n<ul>\n<li>LinkedHashSet maintains the order of element (*Note wherever you found a linked keyword, It will maintain insertion order of element)<\/li>\n<li>LinkedHashSet class is non synchronized.<\/li>\n<\/ul>\n<p><strong>SortedSet<\/strong>\u00a0is a child interface of sets.<\/p>\n<ul>\n<li>Sortedset is an interface in collection.<\/li>\n<li>All elements inserted into a sorted set must implement the Comparable interface.<\/li>\n<li>Sortedset has some useful methods a few mentioned below.<\/li>\n<li>Comparator()<\/li>\n<li>Headset()<\/li>\n<li>Tailset()<\/li>\n<li>subset()<\/li>\n<\/ul>\n<p>Sortedset is implemented a class called TreeSet.<\/p>\n<p><strong>Treeset<\/strong><\/p>\n<ul>\n<li>Treeset It will sort in ascending order.<\/li>\n<li>TreeSet class does not allow duplicate elements.<\/li>\n<li>TreeSet class is non synchronized.<\/li>\n<\/ul>\n<p>Priority queue is the class that implements the queue interface.<\/p>\n<p><strong>PriorityQueue<\/strong><\/p>\n<ul>\n<li>It objects are processed based on their priority.<\/li>\n<li>It does not allow null.<\/li>\n<li>Objects added to PriorityQueue must be comparable.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The java Collection is a framework that helps in storing and manipulating a group of objects,Collections are dynamic and they can grow their size dynamically at run time as the<\/p>\n","protected":false},"author":1,"featured_media":22837,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[77],"tags":[25,26],"class_list":["post-22269","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-design","tag-development"],"_links":{"self":[{"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/posts\/22269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/comments?post=22269"}],"version-history":[{"count":1,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/posts\/22269\/revisions"}],"predecessor-version":[{"id":33866,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/posts\/22269\/revisions\/33866"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/media\/22837"}],"wp:attachment":[{"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/media?parent=22269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/categories?post=22269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cnsfly.com\/vytcdc\/wp-json\/wp\/v2\/tags?post=22269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}