{"id":5433,"date":"2021-10-08T11:57:35","date_gmt":"2021-10-08T11:57:35","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=5433"},"modified":"2024-07-02T11:40:43","modified_gmt":"2024-07-02T11:40:43","slug":"implementing-a-linked-list-in-java-using-class","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/","title":{"rendered":"Implementing a Linked List in Java using Class"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png\" alt=\"\" \/><\/p>\n<p>Linked lists are fundamental data structures in computer science, providing a dynamic and flexible way to store and manage a collection of elements. Unlike arrays, linked lists do not require a contiguous block of memory, allowing for efficient insertions and deletions. In Java, implementing a linked list using classes involves creating a series of nodes, where each node contains data and a reference to the next node in the sequence. This approach not only helps in understanding the underlying mechanics of data structures but also enhances problem-solving skills by providing a hands-on experience with dynamic memory management.<\/p>\n<h2>Linked List Creation<\/h2>\n<p><strong>Structure of a node:<\/strong><br \/>\nEach linked list node consists of 2 parts:<\/p>\n<ul>\n<li><strong>Data:<\/strong> The Data which is stored at a particular address.<\/li>\n<li><strong>Reference:<\/strong> Contains the address of the next node of the linked list.<\/li>\n<\/ul>\n<p><strong>Creating class Node:<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5434 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_5434 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_5434 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5434 .wpsm_nav-tabs > li.active > a, #tab_container_5434 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5434 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_5434 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_5434 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5434 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5434 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5434 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5434 .wpsm_nav-tabs > li > a:hover , #tab_container_5434 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_5434 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_5434 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_5434 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_5434 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_5434 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_5434 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_5434 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5434 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_5434 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5434 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_5434 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_5434\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5434\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_5434_1\" aria-controls=\"tabs_desc_5434_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_5434\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_5434_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nclass Node {\r\n    int data;\r\n    Node next;\r\n\r\n    public Node(int data) {\r\n        this.data = data;\r\n        this.next = null;\r\n    }\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_5434 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_5434 a\"),jQuery(\"#tab-content_5434\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_2-3.png\" alt=\"\" \/><\/p>\n<p>A  linked List can be created by linking together the nodes. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes.com\/blog\/wp-content\/uploads\/2021\/10\/p_1-4.png\" alt=\"\" \/><\/p>\n<ul>\n<li>The first node of the list is called a <strong>head<\/strong>, and the last node of the list is called a <strong>tail<\/strong>. <\/li>\n<li>Each and every node in the list can be accessed by traversing through the list from <strong>head<\/strong> to <strong>tail<\/strong>.<\/li>\n<\/ul>\n<p>In this article, we will be explaining how to add a new node in the linked list at the end or at any specified position. We will also explain how to delete any existing node in the Linked List.<\/p>\n<h2>Insertion Operations<\/h2>\n<h3>Inserting at the end of the linked list<\/h3>\n<p>In this, we will insert a new node at the end of the Linked List. <\/p>\n<p>For example, if we have a Linked List  2\u21924\u21926\u21928\u219210, and we want to insert 12 at the end of the linked list.<\/p>\n<ul>\n<li>After inserting 12 at the end of the given linked list, our updated linked list will be: 2\u21924\u21926\u21928\u219210\u219212.<\/li>\n<\/ul>\n<h3>Algorithm To Create Linked List In Java Using Class<\/h3>\n<ul>\n<li>As a Linked List is represented by the <strong>head<\/strong> pointer, so to insert a new node at the end of the linked list, we will use another pointer <strong>tail<\/strong> which will always point to the last node of the list.<\/li>\n<li>First, we will create a new node to be inserted, let\u2019s say <strong>new_node<\/strong>, with given data.<\/li>\n<li>Then we will check if the <strong>head<\/strong> is null or not.\n<ul>\n<li>If the <strong>head<\/strong> is null, then make:<\/li>\n<li>head = new_node<\/li>\n<li>tail = new_node<\/li>\n<li>Else, if the <strong>head<\/strong> is not null, then make:<\/li>\n<li>tail.next = new_node<\/li>\n<li>tail = new_node<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Code Implementation To Create Linked List In Java Using Class<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5435 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_5435 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_5435 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5435 .wpsm_nav-tabs > li.active > a, #tab_container_5435 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5435 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_5435 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_5435 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5435 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5435 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5435 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5435 .wpsm_nav-tabs > li > a:hover , #tab_container_5435 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_5435 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_5435 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_5435 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_5435 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_5435 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_5435 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_5435 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5435 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_5435 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5435 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_5435 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_5435\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5435\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_5435_1\" aria-controls=\"tabs_desc_5435_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_5435\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_5435_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\npublic class InsertNode {\r\n    \/\/ Linked list node structure\r\n    class Node {\r\n        int data;\r\n        Node next;\r\n\r\n        public Node(int data) {\r\n            this.data = data;\r\n            this.next = null;\r\n        }\r\n    }\r\n\r\n    public Node head = null;\r\n    public Node tail = null;\r\n\r\n    \/\/ addNode() it will add a new node at the end of the linked list\r\n    public void addNode(int data) {\r\n        \/\/ Creating a new node\r\n        System.out.println(&quot;Adding a new node with value &quot;+data+&quot; at the end of the linked list &quot;);\r\n        Node new_Node = new Node(data);\r\n\r\n        \/\/ it will check if the list is empty or not\r\n        if (head == null) {\r\n            \/\/ when list is empty,head and tail point to new node\r\n            head = new_Node;\r\n            tail = new_Node;\r\n        } else {\r\n            \/\/ new_Node will be added after tail such that tail's next will point to newNode\r\n            tail.next = new_Node;\r\n            \/\/ new_Node will become new tail of the list\r\n            tail = new_Node;\r\n        }\r\n    }\r\n\r\n    \/\/ PrintData() will display all the nodes present in the list\r\n    public void PrintData() {\r\n\r\n        Node current = head;\r\n        if (head == null) {\r\n            System.out.println(&quot;Linked List is empty&quot;);\r\n            return;\r\n        }\r\n        while (current != null) {\r\n            \/\/ It will print each node by incrementing pointer\r\n            System.out.print(current.data + &quot; &quot;);\r\n            current = current.next;\r\n        }\r\n        System.out.println();\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n\r\n        InsertNode List = new InsertNode();\r\n\r\n        \/\/ Add 5 to the end of the list\r\n        List.addNode(5);\r\n        List.PrintData();\r\n\r\n        \/\/ Add 4 to the end of the list\r\n        List.addNode(4);\r\n        List.PrintData();\r\n\r\n        \/\/ Add 3 to the end of the list\r\n        List.addNode(3);\r\n        List.PrintData();\r\n\r\n        \/\/ Add 2 to the end of the list\r\n        List.addNode(2);\r\n        List.PrintData();\r\n    }\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_5435 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_5435 a\"),jQuery(\"#tab-content_5435\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p>    Output<br \/>\n    Adding a new node with value 5 at the end of the linked list<br \/>\n    5<br \/>\n    Adding a new node with value 4 at the end of the linked list<br \/>\n    5 4<br \/>\n    Adding a new node with value 3 at the end of the linked list<br \/>\n    5 4 3<br \/>\n    Adding a new node with value 2 at the end of the linked list<br \/>\n    5 4 3 2<\/p>\n<h3>Inserting at specific position in the linked list<\/h3>\n<p>In this method, we will traverse up to <strong>n<\/strong> elements, where <strong>n<\/strong> is equal to given position and add the node at that position.<\/p>\n<p>For example, if we have a Linked List 1\u21922\u21923\u21924, and we want to insert a node with data = 5 at the 2<sup>nd<\/sup> position in the linked list.<\/p>\n<ul>\n<li>After inserting a new node with data = 5 at 2<sup>nd<\/sup> position in our linked list, our resultant linked list will look like: 1\u21922\u21925\u21923\u21924.<\/li>\n<li><strong>Note:<\/strong> Take 0 based indexing while finding positions.<\/li>\n<\/ul>\n<h3>Algorithm To Create Linked List In Java Using Class<\/h3>\n<ul>\n<li>If the position is equal to 1, add the <strong>new_node<\/strong> before the <strong>head node<\/strong>.\n<ul>\n<li>new_node.nextNode = headNode;<\/li>\n<li>head = new_node;<\/li>\n<\/ul>\n<\/li>\n<li>Otherwise, iterate up to the <strong>specified position<\/strong> using <strong>headNode<\/strong> and then do the following steps:\n<ul>\n<li>new_node.nextNode = headNode.nextNode;<\/li>\n<li>headNode.nextNode = new_node;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Note:<\/strong> Variables names in the algorithm are the same as that in code, so for better understanding, go through code and algorithm at the same time.<\/p>\n<h3>Code Implementation To Create Linked List In Java Using Class<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5436 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_5436 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_5436 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5436 .wpsm_nav-tabs > li.active > a, #tab_container_5436 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5436 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_5436 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_5436 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5436 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5436 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5436 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5436 .wpsm_nav-tabs > li > a:hover , #tab_container_5436 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_5436 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_5436 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_5436 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_5436 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_5436 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_5436 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_5436 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5436 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_5436 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5436 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_5436 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_5436\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5436\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_5436_1\" aria-controls=\"tabs_desc_5436_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_5436\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_5436_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\npublic class InsertNode {\r\n    \/\/ Linked list node structure\r\n    static class Node {\r\n        public int data;\r\n        public Node nextNode;\r\n\r\n        \/\/ Constructor\r\n        public Node(int data) {\r\n            this.data = data;\r\n\r\n        }\r\n    }\r\n\r\n    \/\/ Method to insert a node at position pos.\r\n    static Node Insert(Node headNode, int pos, int data) {\r\n        Node head = headNode;\r\n        if (pos &lt; 1)\r\n            System.out.print(&quot;Invalid pos&quot;);\r\n\r\n        if (pos == 1) {\r\n            Node new_node = new Node(data);\r\n            new_node.nextNode = headNode;\r\n            head = new_node;\r\n        } else {\r\n            while (pos-- != 0) {\r\n                if (pos == 1) {\r\n\r\n                    Node new_node = new Node(data);\r\n\r\n                    new_node.nextNode = headNode.nextNode;\r\n                    headNode.nextNode = new_node;\r\n                    break;\r\n                }\r\n                headNode = headNode.nextNode;\r\n            }\r\n            if (pos != 1)\r\n                System.out.print(&quot;Position out of bound&quot;);\r\n        }\r\n        return head;\r\n    }\r\n    \/\/ PrintData() will display all the nodes present in the list\r\n    static void PrintData(Node node) {\r\n        while (node != null) {\r\n            System.out.print(node.data);\r\n            node = node.nextNode;\r\n            if (node != null)\r\n                System.out.print(&quot;-&gt;&quot;);\r\n        }\r\n        System.out.println();\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        Node head = new Node(1);\r\n        head.nextNode = new Node(2);\r\n        head.nextNode.nextNode = new Node(3);\r\n        head.nextNode.nextNode.nextNode = new Node(4);\r\n\r\n        System.out.print(&quot;Original Linked List: &quot;);\r\n        PrintData(head);\r\n\r\n        \/\/ Insert a node at any position\r\n        int data = 24, pos = 5;\r\n        head = Insert(head, pos, data);\r\n        System.out.print(&quot;Linked list after adding a node with data &quot;+data+&quot; at position &quot;+pos+&quot;: &quot;);\r\n        PrintData(head);\r\n\r\n        \/\/ Inserting a node at first position\r\n        data = 39;\r\n        pos = 1;\r\n        head = Insert(head, pos, data);\r\n        System.out.print(&quot;Linked list after adding a node with data &quot;+data+&quot; at position &quot;+pos+&quot;: &quot;);\r\n        PrintData(head);\r\n\r\n        data = 18;\r\n        pos = 7;\r\n        head = Insert(head, pos, data);\r\n        System.out.print(&quot;Linked list after adding a node with data &quot;+data+&quot; at position &quot;+pos+&quot;: &quot;);\r\n        PrintData(head);\r\n    }\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_5436 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_5436 a\"),jQuery(\"#tab-content_5436\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p>    Output<br \/>\n    Original Linked List: 1-&gt;2-&gt;3-&gt;4<br \/>\n    Linked list after adding a node with data 24 at position 5: 1-&gt;2-&gt;3-&gt;4-&gt;24<br \/>\n    Linked list after adding a node with data 39 at position 1: 39-&gt;1-&gt;2-&gt;3-&gt;4-&gt;24<br \/>\n    Linked list after adding a node with data 18 at position 7: 39-&gt;1-&gt;2-&gt;3-&gt;4-&gt;24-&gt;18<\/p>\n<h2>Deletion Operations<\/h2>\n<p>In this section, we will see how to delete the first occurrence of the specified node from the linked list, i.e., deleting the first occurrence of a given <strong>key<\/strong> from the linked list.<\/p>\n<p>For example, if we have a Linked List  2\u21924\u21926\u21924\u219210, and we want to delete the first occurrence of node with value 4 <strong>(key = 4)<\/strong> from the linked list. <\/p>\n<ul>\n<li>After deleting the first occurrence of node with value 4 from the linked list, our resultant linked list will be: 2\u21926\u21924\u219210.<\/li>\n<\/ul>\n<h3>Algorithm To Create Linked List In Java Using Class<\/h3>\n<ul>\n<li>\n<p><strong>Condition1:<\/strong> If the <strong>key<\/strong> is at the head.<\/p>\n<ul>\n<li>Change the <strong>head node<\/strong> to the <strong>next node<\/strong> of the <strong>current head<\/strong>.<\/li>\n<li>list.head = current_Node.next;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Condition 2:<\/strong> The key is either in the <strong>middle<\/strong> or <strong>last<\/strong>, except at the <strong>head<\/strong>.<\/p>\n<ul>\n<li>\n<p>In this condition, find the <strong>previous node<\/strong> of the node to be deleted.<\/p>\n<\/li>\n<li>\n<p>prev = current_Node;<\/p>\n<\/li>\n<li>\n<p>current_Node = current_Node.next;<\/p>\n<\/li>\n<li>\n<p>Make the <strong>previous node<\/strong> of the node to be deleted point to the next node of the <strong>current node<\/strong>.<\/p>\n<\/li>\n<li>\n<p>prev.next = current_Node.next;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Condition 3:<\/strong> The key is not in the list.<\/p>\n<ul>\n<li>Print <strong>key not found<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Note:<\/strong> Variables names in the algorithm are the same as that in code, so for better understanding, go through code and algorithm at the same time.<\/p>\n<h3>Code Implementation To Create Linked List In Java Using Class<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_5437 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_5437 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_5437 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_5437 .wpsm_nav-tabs > li.active > a, #tab_container_5437 .wpsm_nav-tabs > li.active > a:hover, #tab_container_5437 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_5437 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_5437 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_5437 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_5437 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_5437 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_5437 .wpsm_nav-tabs > li > a:hover , #tab_container_5437 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_5437 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_5437 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_5437 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_5437 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_5437 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_5437 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_5437 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5437 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_5437 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_5437 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_5437 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_5437\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_5437\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_5437_1\" aria-controls=\"tabs_desc_5437_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_5437\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_5437_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\npublic class LinkedList {\r\n\r\n    Node head;\r\n    \/\/ Linked list node structure\r\n    static class Node {\r\n\r\n        int data;\r\n        Node next;\r\n\r\n        \/\/ Constructor\r\n        Node(int d)\r\n        {\r\n            data = d;\r\n            next = null;\r\n        }\r\n    }\r\n\r\n    public static LinkedList value(LinkedList list, int data)\r\n    {\r\n        \r\n        Node new_node = new Node(data);\r\n        new_node.next = null;\r\n\r\n        if (list.head == null) {\r\n            list.head = new_node;\r\n        }\r\n        else {\r\n            Node last = list.head;\r\n            while (last.next != null) {\r\n                last = last.next;\r\n            }\r\n\r\n            last.next = new_node;\r\n        }\r\n\r\n        return list;\r\n    }\r\n\r\n    public static void printData(LinkedList list)\r\n    {\r\n        Node current_Node = list.head;\r\n    \r\n        System.out.print(&quot;Linked List :- &quot;);\r\n\r\n        while (current_Node != null) {\r\n            System.out.print(current_Node.data + &quot; &quot;);\r\n            current_Node = current_Node.next;\r\n        }\r\n        System.out.println();\r\n    }\r\n \r\n    \/\/ Method to delete the node with data equal to specified key\r\n    public static LinkedList deleteNode(LinkedList list,int key)\r\n    {\r\n        \r\n        Node current_Node = list.head, prev = null;\r\n \r\n        \/\/ Condition 1: Key is  at head\r\n        if (current_Node != null &amp;&amp; current_Node.data == key) {\r\n            list.head = current_Node.next;\r\n            System.out.println(key + &quot; is found and deleted&quot;);\r\n\r\n            return list;\r\n        }\r\n        \r\n        \/\/ Condition 2\r\n        while (current_Node != null &amp;&amp; current_Node.data != key) {\r\n            prev = current_Node;\r\n            current_Node = current_Node.next;\r\n        }\r\n\r\n        if (current_Node != null) {\r\n            prev.next = current_Node.next;\r\n            System.out.println(key + &quot; is found and deleted&quot;);\r\n        }\r\n \r\n        \/\/ Condition 3: The key is not  in the list\r\n        if (current_Node == null) {\r\n            System.out.println(key + &quot; not found&quot;);\r\n        }\r\n\r\n        return list;\r\n    }\r\n \r\n    \r\n    \/\/ Driver code\r\n    public static void main(String[] args)\r\n    {\r\n        LinkedList list = new LinkedList();\r\n        \r\n        list = value(list, 2);\r\n        list = value(list, 6);\r\n        list = value(list, 1);\r\n        list = value(list, 8);\r\n        list = value(list, 9);\r\n        list = value(list, 0);\r\n        list = value(list, 3);\r\n        list = value(list, 5);\r\n\r\n        printData(list);\r\n        deleteNode(list, 2);\r\n        printData(list);\r\n\r\n        deleteNode(list, 8);\r\n        printData(list);\r\n\r\n        deleteNode(list, 20);\r\n        printData(list);\r\n    }\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_5437 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_5437 a\"),jQuery(\"#tab-content_5437\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p>    Output<br \/>\n    Linked List :- 2 6 1 8 9 0 3 5<br \/>\n    2 is found and deleted<br \/>\n    Linked List :- 6 1 8 9 0 3 5<br \/>\n    8 is found and deleted<br \/>\n    Linked List :- 6 1 9 0 3 5<br \/>\n    20 not found<br \/>\n    Linked List :- 6 1 9 0 3 5<\/p>\n<p>**Conclusion**<br \/>\nImplementing a linked list in Java using classes offers a deep dive into one of the most important data structures in computer science. By understanding how nodes are created, linked, and managed, developers gain valuable insights into dynamic memory allocation and data organization. Linked lists are versatile and form the foundation for more complex data structures like stacks, queues, and graphs. Mastering linked list implementation enhances a programmer&#8217;s ability to solve a wide range of computational problems efficiently.<\/p>\n<p>## FAQs Related to Implementing a Linked List in Java using Class<br \/>\nHere are some of the FAQs related to Implementing a Linked List in Java using Class:<\/p>\n<p>**Q1: What is a linked list?**<br \/>\nA linked list is a linear data structure where elements are stored in nodes, and each node contains data and a reference (or link) to the next node in the sequence. Unlike arrays, linked lists do not require a contiguous block of memory, making them more flexible for dynamic memory allocation.<\/p>\n<p>**Q2: What are the types of linked lists?**<br \/>\n There are several types of linked lists:<\/p>\n<p>&#8211; **Singly Linked List:** Each node points to the next node, and the last node points to null.<br \/>\n&#8211; **Doubly Linked List:** Each node has two references, one to the next node and one to the previous node.<br \/>\n&#8211; **Circular Linked List:** The last node points back to the first node, forming a circle.<\/p>\n<p>**Q3: What are the advantages of using a linked list over an array?**<br \/>\nThe advantages of using a linked list over an array include:<\/p>\n<p>&#8211; **Dynamic Size:** Linked lists can grow and shrink in size dynamically, while arrays have a fixed size.<br \/>\n&#8211; **Efficient Insertions\/Deletions:** Insertions and deletions are more efficient in linked lists, especially for large data sets, because they do not require shifting elements as arrays do.<\/p>\n<p>**Q4: What are the disadvantages of using a linked list?**<br \/>\nThe disadvantages of using a linked list include:<\/p>\n<p>&#8211; **Memory Overhead:** Linked lists require extra memory for storing references to the next (and previous, in doubly linked lists) nodes.<br \/>\n&#8211; **Sequential Access:** Linked lists do not support efficient random access to elements, unlike arrays, which offer constant-time access based on index.<\/p>\n<p>**Q5: How can linked lists be used in real-world applications?**<br \/>\nLinked lists are used in various real-world applications, such as:<\/p>\n<p>&#8211; **Dynamic Memory Allocation:** Used in operating systems for managing free memory.<br \/>\n&#8211; **Implementing Data Structures:** Used to implement other data structures like stacks, queues, and graphs.<br \/>\n&#8211; **Navigating Previous and Next:** Used in applications like web browsers for back and forward navigation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linked lists are fundamental data structures in computer science, providing a dynamic and flexible way to store and manage a collection of elements. Unlike arrays, linked lists do not require a contiguous block of memory, allowing for efficient insertions and deletions. In Java, implementing a linked list using classes involves creating a series of nodes, [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[143],"tags":[],"class_list":["post-5433","post","type-post","status-publish","format-standard","hentry","category-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Implementing a Linked List in Java using Class<\/title>\n<meta name=\"description\" content=\"This article explains how you can add a new node in the linked list at the end or at any specified position.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implementing a Linked List in Java using Class\" \/>\n<meta property=\"og:description\" content=\"This article explains how you can add a new node in the linked list at the end or at any specified position.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-08T11:57:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-02T11:40:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png\" \/>\n<meta name=\"author\" content=\"PrepBytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"PrepBytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Implementing a Linked List in Java using Class\",\"datePublished\":\"2021-10-08T11:57:35+00:00\",\"dateModified\":\"2024-07-02T11:40:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\"},\"wordCount\":1393,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\",\"name\":\"Implementing a Linked List in Java using Class\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png\",\"datePublished\":\"2021-10-08T11:57:35+00:00\",\"dateModified\":\"2024-07-02T11:40:43+00:00\",\"description\":\"This article explains how you can add a new node in the linked list at the end or at any specified position.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Implementing a Linked List in Java using Class\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\",\"name\":\"PrepBytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"caption\":\"PrepBytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Implementing a Linked List in Java using Class","description":"This article explains how you can add a new node in the linked list at the end or at any specified position.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/","og_locale":"en_US","og_type":"article","og_title":"Implementing a Linked List in Java using Class","og_description":"This article explains how you can add a new node in the linked list at the end or at any specified position.","og_url":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2021-10-08T11:57:35+00:00","article_modified_time":"2024-07-02T11:40:43+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png","type":"","width":"","height":""}],"author":"PrepBytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PrepBytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Implementing a Linked List in Java using Class","datePublished":"2021-10-08T11:57:35+00:00","dateModified":"2024-07-02T11:40:43+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/"},"wordCount":1393,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/","url":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/","name":"Implementing a Linked List in Java using Class","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png","datePublished":"2021-10-08T11:57:35+00:00","dateModified":"2024-07-02T11:40:43+00:00","description":"This article explains how you can add a new node in the linked list at the end or at any specified position.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1719920430471-Implementing%20a%20Linked%20List%20in%20Java%20using%20Class.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/implementing-a-linked-list-in-java-using-class\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/prepbytes.com\/blog\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Implementing a Linked List in Java using Class"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e","name":"PrepBytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","caption":"PrepBytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=5433"}],"version-history":[{"count":6,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5433\/revisions"}],"predecessor-version":[{"id":19203,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/5433\/revisions\/19203"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=5433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=5433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=5433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}