{"id":65912,"date":"2021-07-17T04:10:04","date_gmt":"2021-07-17T08:10:04","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/linked-list-and-iterator-in-java-java-short-notes\/"},"modified":"2021-07-17T04:10:04","modified_gmt":"2021-07-17T08:10:04","slug":"linked-list-and-iterator-in-java-java-short-notes","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65912","title":{"rendered":"Linked List and Iterator in Java #Java Short Notes"},"content":{"rendered":"<p><pre style='padding-left:5px;padding-right:5px'>\/* * LinkedList.java * * Created on January 10, 2008, 8:51 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. *\/package linkedlist;import java.util.List;import java.util.LinkedList;import java.util.Iterator;import java.util.ListIterator;import java.util.Collections;import java.util.Random;\/** * * @author Sayed *\/public class LinkedListTest {        \/** Creates a new instance of LinkedList *\/    public LinkedListTest() {    }        \/**     *Example operations using linked lists     *\/        public void linkedListOperation(){                final int MAX = 10;        int counter = 0;        \/\/create two linked lists        List listA = new LinkedList();        List listB = new LinkedList();        \/\/store data in the linked list A        for (int i = 0; i &lt; MAX; i++) {            System.out.println(&quot;  - Storing Integer(&quot; + i + &quot;)&quot;);            listA.add(new Integer(i));        }               \/\/print data from the linked list using iterator         Iterator it = listA.iterator();        while (it.hasNext()) {            System.out.println(it.next());        }        \/\/print data from the linked list using listIterator.         counter = 0;        ListIterator liIt = listA.listIterator();        while (liIt.hasNext()) {            System.out.println(&quot;Element [&quot; + counter + &quot;] = &quot; + liIt.next());            System.out.println(&quot;  - hasPrevious    = &quot; + liIt.hasPrevious());            System.out.println(&quot;  - hasNext        = &quot; + liIt.hasNext());            System.out.println(&quot;  - previousIndex  = &quot; + liIt.previousIndex());            System.out.println(&quot;  - nextIndex      = &quot; + liIt.nextIndex());            System.out.println();            counter++;        }        \/\/retrieve data from the linked list using index        for (int j=0; j &lt; listA.size(); j++) {            System.out.println(&quot;[&quot; + j + &quot;] - &quot; + listA.get(j));        }        \/\/find the location of an element        int locationIndex = listA.indexOf(&quot;5&quot;);        System.out.println(&quot;Index location of the String &quot;5&quot;&quot; is: &quot;&quot; + locationIndex);          \/\/find the first and the last location of an element        System.out.println(&quot;&quot;First occurance search for String &quot;&quot;5&quot;&quot;.  Index =  &quot;&quot; + \t\tlistA.indexOf(&quot;&quot;5&quot;&quot;));        System.out.println(&quot;&quot;Last Index search for String &quot;&quot;5&quot;&quot;.       Index =  &quot;&quot; + \t\tlistA.lastIndexOf(&quot;&quot;5&quot;&quot;));        \/\/create a sublist from the list         List listSub = listA.subList(10<\/pre>\n<\/p>\n<p> From: http:\/\/sitestree.com\/?p=4788<br \/> Categories:Java Short Notes<br \/>Tags:<br \/> Post Data:2013-04-04 09:12:30<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* * LinkedList.java * * Created on January 10, 2008, 8:51 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. *\/package linkedlist;import java.util.List;import java.util.LinkedList;import java.util.Iterator;import java.util.ListIterator;import java.util.Collections;import java.util.Random;\/** * * @author Sayed *\/public class LinkedListTest { \/** Creates a new instance of LinkedList *\/ &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65912\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-65912","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10102,"url":"http:\/\/bangla.sitestree.com\/?p=10102","url_meta":{"origin":65912,"position":0},"title":"J2SE : LinkedList and Iterators in Java","author":"","date":"July 31, 2015","format":false,"excerpt":"\/* \u00a0* LinkedList.java \u00a0* \u00a0* Created on January 10, 2008, 8:51 PM \u00a0* \u00a0* To change this template, choose Tools | Template Manager \u00a0* and open the template in the editor. \u00a0*\/ package linkedlist; import java.util.List; import java.util.LinkedList; import java.util.Iterator; import java.util.ListIterator; import java.util.Collections; import java.util.Random; \/** \u00a0* \u00a0* @author\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26862,"url":"http:\/\/bangla.sitestree.com\/?p=26862","url_meta":{"origin":65912,"position":1},"title":"LinkedList and Iterators in Java #Programming Code Examples #Java\/J2EE\/J2ME #J2SE","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"\/* * LinkedList.java * * Created on January 10, 2008, 8:51 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. *\/ package linkedlist; import java.util.List; import java.util.LinkedList; import java.util.Iterator; import java.util.ListIterator; import java.util.Collections; import java.util.Random; \/** * * @author\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":23218,"url":"http:\/\/bangla.sitestree.com\/?p=23218","url_meta":{"origin":65912,"position":2},"title":"Linked List and Iterator in Java #Root #By Sayed Ahmed","author":"Author-Check- Article-or-Video","date":"March 27, 2021","format":false,"excerpt":"By Sayed: 8 [use Firefox or IE with large font size] \/* * LinkedList.java * * Created on January 10, 2008, 8:51 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. *\/ package linkedlist; import java.util.List; import java.util.LinkedList; import\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65876,"url":"http:\/\/bangla.sitestree.com\/?p=65876","url_meta":{"origin":65912,"position":3},"title":"Set, TreeSet, Iterator in Java #Java Short Notes #Blog","author":"Author-Check- Article-or-Video","date":"July 16, 2021","format":false,"excerpt":"\/* * TreeSetExample.java * *Illustrates mathematical set operations * * Created on January 10, 2008, 9:28 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. *\/package treesetexample;import java.util.Set;import java.util.TreeSet;import java.util.Iterator;\/** * * @author Sayed *\/public class TreeSetExample { \/**\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10104,"url":"http:\/\/bangla.sitestree.com\/?p=10104","url_meta":{"origin":65912,"position":4},"title":"Example Java Programs","author":"","date":"August 3, 2015","format":false,"excerpt":"HelloWorld.java public class HelloWorld { \u00a0\u00a0\u00a0 \/\/ method main(): ALWAYS the APPLICATION entry point \u00a0\u00a0\u00a0 public static void main (String[] args) { \u00a0\u00a0 \u00a0System.out.println (\"Hello World!\"); \u00a0\u00a0\u00a0 } } \/\/ Print Today's Date import java.util.*; public class HelloDate { \u00a0\u00a0\u00a0 public static void main (String[] args) { \u00a0\u00a0 \u00a0System.out.println (\"Hello,\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26864,"url":"http:\/\/bangla.sitestree.com\/?p=26864","url_meta":{"origin":65912,"position":5},"title":"Example Java Programs #Programming Code Examples #Java\/J2EE\/J2ME #J2SE","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"Very Simple Java Example Programs HelloWorld.java public class HelloWorld { \/\/ method main(): ALWAYS the APPLICATION entry point public static void main (String[] args) { System.out.println (\"Hello World!\"); } } \/\/ Print Today's Date import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println (\"Hello, it's:\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65912"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65912\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65912"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}