{"id":3248,"date":"2020-02-12T19:07:51","date_gmt":"2020-02-12T13:37:51","guid":{"rendered":"https:\/\/cns72.com\/vytcdc.com.sg\/?p=3248"},"modified":"2020-12-10T20:45:11","modified_gmt":"2020-12-10T15:15:11","slug":"what-is-collection-in-java","status":"publish","type":"post","link":"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-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 <a href=\"https:\/\/cns72.com\/vytcdc.com.sg\/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 <\/strong>\u2013List allows duplicate objects.<\/p>\n<p><strong>Sets<\/strong> \u2013 Does not allow duplicate objects.<\/p>\n<p><strong>Queue<\/strong>\u2013It is a First in First out Data structure.<\/p>\n<p>&nbsp;<\/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>&nbsp;<\/p>\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>&nbsp;<\/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>&nbsp;<\/p>\n<p><strong>SortedSet<\/strong> is 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<\/ul>\n<p>&nbsp;<\/p>\n<ul>\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>&nbsp;<\/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>&nbsp;<\/p>\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<p>&nbsp;<\/p>\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 elements are added to it. The Collection is a root interface available in java.util.package.This is Implemented by three interfaces in Java Program. List Sets Queue [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3252,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[63],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Collection in java - TCDC<\/title>\n<link rel=\"canonical\" href=\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Collection in java - TCDC\" \/>\n<meta property=\"og:description\" content=\"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. The Collection is a root interface available in java.util.package.This is Implemented by three interfaces in Java Program. List Sets Queue [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"TCDC\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vytcdc\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-12T13:37:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-10T15:15:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cns72.com\/vytcdc.com.sg\/wp-content\/uploads\/2020\/02\/collection.png\" \/>\n\t<meta property=\"og:image:width\" content=\"624\" \/>\n\t<meta property=\"og:image:height\" content=\"325\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vytcdc\" \/>\n<meta name=\"twitter:site\" content=\"@vytcdc\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/#website\",\"url\":\"https:\/\/cns72.com\/vytcdc.com.sg\/\",\"name\":\"TCDC\",\"description\":\"Career Development Courses\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/cns72.com\/vytcdc.com.sg\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/cns72.com\/vytcdc.com.sg\/wp-content\/uploads\/2020\/02\/collection.png\",\"width\":624,\"height\":325},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/#webpage\",\"url\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/\",\"name\":\"Collection in java - TCDC\",\"isPartOf\":{\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/#primaryimage\"},\"datePublished\":\"2020-02-12T13:37:51+00:00\",\"dateModified\":\"2020-12-10T15:15:11+00:00\",\"author\":{\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/#\/schema\/person\/c57e5f7b91685a93f23a57aaafd38e82\"},\"breadcrumb\":{\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/\",\"url\":\"https:\/\/cns72.com\/vytcdc.com.sg\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/\",\"url\":\"https:\/\/cns72.com\/vytcdc.com.sg\/what-is-collection-in-java\/\",\"name\":\"Collection in java\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/#\/schema\/person\/c57e5f7b91685a93f23a57aaafd38e82\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cns72.com\/vytcdc.com.sg\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f8f959f70994a4401c8704d6b2143474?s=96&d=mm&r=g\",\"caption\":\"admin\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/posts\/3248"}],"collection":[{"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/comments?post=3248"}],"version-history":[{"count":0,"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/posts\/3248\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/media\/3252"}],"wp:attachment":[{"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/media?parent=3248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/categories?post=3248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cns72.com\/vytcdc.com.sg\/wp-json\/wp\/v2\/tags?post=3248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}