[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-685692-105":59,"doc-detail-685692-en":130,"doc-similar-685692":148},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","arraylist-vs-linkedlist-for-introduction-to-java-programming-performance-comparison","ArrayList vs LinkedList - For Introduction to Java Programming - Performance Comparison","","ArrayList and LinkedList are both list data structures in Java with overlapping operations, yet they differ in performance for specific tasks. This supplement explains why both are needed by focusing on insertion/deletion at the beginning of a list versus other operations. It presents two Java examples: one inserts one million integers at the front, and another retrieves elements at random indices, showing contrasting timing results between the two implementations.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/arraylist-vs-linkedlist-for-introduction-to-java-programming-performance-comparison/685692/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/arraylist-vs-linkedlist-for-introduction-to-java-programming-performance-comparison/685692.png","ImageObject",300,407,{"name":92,"@type":93},"The weather in my hometown","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-12","2026-11-07",true,{"@type":102,"interactionType":103,"userInteractionCount":19},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"Why do we need both ArrayList and LinkedList if they support similar operations?","Question",{"text":112,"@type":113},"They can perform the same kinds of list operations, but their performance differs depending on what you do. The document explains that LinkedList is efficient for inserting/deleting at the beginning, while ArrayList is efficient for other operations.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What does Listing 1 demonstrate about ArrayList vs LinkedList?",{"text":117,"@type":113},"Listing 1 inserts one million integers at the beginning of both structures. The sample output shows LinkedList is much faster than ArrayList for this front-insertion workload.",{"name":119,"@type":110,"acceptedAnswer":120},"How does Listing 2 compare their performance for retrieving elements?",{"text":121,"@type":113},"Listing 2 first fills each list with one million elements, then retrieves elements at random indices. The sample output indicates ArrayList is much faster than LinkedList for this random-access retrieval test.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},685692,1794016770,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":19,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":81,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":129,"read_time":39,"preview_page_count":8,"preview_urls":143},1374408744247,"https://ap-avatar.wpscdn.com/avatar/14001251d37d565ec6f?x-image-process=image/resize,m_fixed,w_180,h_180&k=1790672120290115972","ArrayList vs LinkedList  \nFor Introduction to Java Programming  \nBy Y. Daniel Liang  \nNote: you can read this supplement with Chapter 20.  \nArrayList and LinkedList both are List for storing a sequence of elements. These two data structures have the same operations for processing and manipulating data. Why do we need these two data structures with the same functionality? Can we just use one of the two? The answer is that we need both, because they have different performance of certain operations. LinkedList is efficient of inserting and deleting elements at the beginning of a list and ArrayList is efficient for all other operations.  \nThis supplement gives two examples that demonstrate the performance of these two data structures. You will know why their performance is different when you learn how these two data structures are implemented later in the text.  \nListing 1 gives an example that inserts one million integers to the beginning of an ArrayList and a LinkedList . From the sample output, you see that LinkedList is much faster than an ArrayList in this example.  \n[Listing 1 ArrayListvsLinkedList1.java](Listing 1 ArrayListvsLinkedList1.java)  \n1 import java.util.*;  \n2  \n3 public class ArrayListvsLinkedList1 {  \n4 public static void main(String[] args) {  \n5 List\u003CInteger> list1 = new ArrayList\u003C>();  \n6 List\u003CInteger> list2 = new LinkedList\u003C>();  \n7  \n8 test(list1, \"Time for ArrayList is \" );  \n9 test(list2, \"Time for LinkedList is \" );  \n11  \n12 public static void test(List\u003CInteger> list, String title) {  \n13 long startTime = System .currentTimeMillis(); 14  \n15 for (int i = 0 ; i \u003C 1000000 ; i++) {  \n16 list.add(0 , i);  \n17 }  \n18  \n19 long time = System .currentTimeMillis() - startTime;  \n20 System .out .println(title + time + \" milliseconds\"); 21 }  \n22 }  \n\u003Cmargin note (line 8)>using ArrayList \u003Cmargin note (line 9)>using LinkedList \u003Cmargin note (line 16)>insert an element \u003Cmargin note (line 19)>get time \u003Cend Listing 1>  \n\u003Coutput>  \nTime for ArrayList is 82919 milliseconds Time for LinkedList is 264 milliseconds  \n\u003Cend output>  \nListing 2 gives an example that retrieves an element from a given index in the list.  \n[Listing 2 ArrayListvsLinkedList2.java](Listing 2 ArrayListvsLinkedList2.java)  \n1 import java.util.ArrayList;  \n2 import java.util.LinkedList;  \n3 import java.util.List;  \n4  \n5 public class ArrayListvsLinkedList2 {  \n6 public static void main(String[] args) {  \n7 List\u003CInteger> list1 = new ArrayList\u003C>();  \n8 List\u003CInteger> list2 = new LinkedList\u003C>();  \n9  \n10 test(list1, \"Time for ArrayList is \" );  \n11 test(list2, \"Time for LinkedList is \" );  \n12 }  \n13  \n14 public static void test(List\u003CInteger> list, String title) {  \n15 for (int i = 0 ; i \u003C 1000000 ; i++) {  \n16 list.add(i);  \n17 }  \n19 long startTime = System .currentTimeMillis();  \n20 for (int i = 0 ; i \u003C 10000 ; i++) {  \n21 list.get((int)(Math .random() * 1000000));  \n22 }  \n23 long time = System .currentTimeMillis() - startTime;  \n24 System .out .println(title + time + \" milliseconds\"); 25 }  \n26 }  \n\u003Cmargin note (line 8)>using ArrayList \u003Cmargin note (line 9)>using LinkedList \u003Cmargin note (line 16)>insert an element \u003Cmargin note (line 19)>get time \u003Cend Listing 1>  \n\u003Coutput>  \nTime for ArrayList is 3 milliseconds Time for LinkedList is 8785 milliseconds  \n\u003Cend output>  \nThe program creates an ArrayList (line 7) and a LinkedList (line 8) and invokes the test method for both lists (lines 10-11) . The test method creates an array of one million elements (lines 15-17) and obtains the time for obtaining an element from the list at a random index (line 21) . As shown in the sample output, the test time for ArrayList is much faster than for the LinkedList.  \nYou may revise the code to test other operations. You will find that ArrayList is better than LinkedList for all operations except inserting and deleting elements at the beginning of the list.","cbCaickVNop2nxB7","https://ap.wps.com/l/cbCaickVNop2nxB7","pdf",72687,"English","# ArrayList and LinkedList Overview\n# Why Both Data Structures Are Needed\n# Performance Example 1: Insert at the Beginning\n## Listing 1 Code and Sample Output\n# Performance Example 2: Retrieve by Index\n## Listing 2 Code and Sample Output\n# Code Revisions and Further Testing","[{\"question\":\"Why do we need both ArrayList and LinkedList if they support similar operations?\",\"answer\":\"They can perform the same kinds of list operations, but their performance differs depending on what you do. The document explains that LinkedList is efficient for inserting/deleting at the beginning, while ArrayList is efficient for other operations.\"},{\"question\":\"What does Listing 1 demonstrate about ArrayList vs LinkedList?\",\"answer\":\"Listing 1 inserts one million integers at the beginning of both structures. The sample output shows LinkedList is much faster than ArrayList for this front-insertion workload.\"},{\"question\":\"How does Listing 2 compare their performance for retrieving elements?\",\"answer\":\"Listing 2 first fills each list with one million elements, then retrieves elements at random indices. The sample output indicates ArrayList is much faster than LinkedList for this random-access retrieval test.\"}]","ArrayList vs LinkedList - For Introduction to Java Programming - Performance Comparison | PDF",[144],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/5f13e5daf4a94cf592be06bee46e4130.webp",983,1272,{"list":149,"token":66},[150,156,162,168,174,180,186,192,198,204],{"doc_id":151,"doc_title":152,"file_type":137,"home_preview_img_url":153,"slug":154,"view_count":34,"category_name":30,"create_tm":155},685695,"High Performance Lists in Java - JavaZone 2015 - Motivation: A Real World Example","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179383/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=qlB%2FjzI1Oq6b8ne2o9N9MMECwJE%3D","high-performance-lists-in-java-javazone-2015-motivation-a-real-world-example",1794016775,{"doc_id":157,"doc_title":158,"file_type":137,"home_preview_img_url":159,"slug":160,"view_count":29,"category_name":30,"create_tm":161},697916,"Java Collections - List Set Map","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010130865/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=oWrC2PbXAX89kXsWcg3FCvwhWdA%3D","java-collections-list-set-map",1794445817,{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":19,"category_name":30,"create_tm":167},719603,"CS1020 Data Structures and Algorithms I Lecture 10 - List ADT & Linked Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230023815866/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=kFnVp3sB4lP0i%2FvcyGc4cDO6GHg%3D","cs1020-data-structures-and-algorithms-i-lecture-10-list-adt-linked-lists",1795006746,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":81,"category_name":30,"create_tm":173},732880,"Linked List Basics - Linked List Basics - Insertion, Deletion, Navigation, and Advanced Operations","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230031780344/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=Nh97P%2BFs5sCpFkT2IEg8pvTSA74%3D","linked-list-basics-linked-list-basics-insertion-deletion-navigation-and-advanced-operations",1795382679,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":29,"category_name":30,"create_tm":179},685666,"Lecture 6 - List ADT","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000175827/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=hwcKZHt4NX0E3CHWIF%2BGSBhR39k%3D","lecture-6-list-adt",1794016534,{"doc_id":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":29,"category_name":30,"create_tm":185},697937,"Doubly Linked List - Basic Operations and Circular Linked List","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010136388/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=BzCnATNGbNbd5v0qcvBAsMA5dTg%3D","doubly-linked-list-basic-operations-and-circular-linked-list",1794446062,{"doc_id":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":19,"category_name":30,"create_tm":191},685727,"Circular Linked Lists - All Operations and Complexity Analysis","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000185859/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=VK8znfnBarsNsh%2FmRTAiH9J4DYU%3D","circular-linked-lists-all-operations-and-complexity-analysis",1794017196,{"doc_id":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":19,"category_name":30,"create_tm":197},685691,"ArrayList and Iterator in Java - Java List Iteration Methods and Examples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179348/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=vznV8dF7GIO49vNPRbfMcAv48qI%3D","arraylist-and-iterator-in-java-java-list-iteration-methods-and-examples",1794016767,{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":29,"category_name":30,"create_tm":203},685764,"Lists and Linked Lists - Part 1 - Introduction","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999691137/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=zt0CMNAY1YycTZjDl4CRP%2FSB4SQ%3D","lists-and-linked-lists-part-1-introduction",1794017635,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":19,"category_name":30,"create_tm":209},719604,"Lecture 17 - Linked List Data Structure (Part-II) - Double Linked List - Applications and Insertion","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230023515168/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111639&Signature=IZSEOIqAcsK%2FfRMc2fPr1zxQxCI%3D","lecture-17-linked-list-data-structure-part-ii-double-linked-list-applications-and-insertion",1795006749]