{"id":19088,"date":"2020-07-06T18:01:29","date_gmt":"2020-07-07T01:01:29","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19088"},"modified":"2023-12-01T03:38:56","modified_gmt":"2023-12-01T11:38:56","slug":"arraylist-java","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/arraylist-java\/","title":{"rendered":"ArrayList Java: A Beginner\u2019s Guide"},"content":{"rendered":"\n<p>Are you tired of having to declare the size of an array before you can use it? You\u2019re not the only one, as it\u2019s not always convenient to have to define how many values an array should store before you can start adding values to that array.<br><\/p>\n\n\n\n<p>That\u2019s where our helpful friend, the Java ArrayList, comes in.<br><\/p>\n\n\n\n<p>In this guide, we\u2019re going to talk about what ArrayLists are, how they work, and how they compare to traditional arrays. We\u2019ll also walk through the most important methods that you need to know about in order to work effectively with the ArrayList class. Let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an ArrayList?<\/h2>\n\n\n\n<p>An ArrayList is a special type of list that allows you to create resizable arrays. The ArrayList class implements the List interface, which is used to store ordered data.<br><\/p>\n\n\n\n<p>When you\u2019re working with an array in Java, you\u2019ve got to declare the size of that array before you can store values within that array. It\u2019s often the case that you don\u2019t know how many values you\u2019ll want to store in an array before you declare it, which presents a problem.<br><\/p>\n\n\n\n<p>The ArrayList class allows you to define an array that doesn\u2019t need to be told how many values it can store. ArrayLists, which are sometimes referred to as <code>dynamic arrays<\/code>, can change their capacity when you add or remove elements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Create an ArrayList<\/h2>\n\n\n\n<p>Let\u2019s get started in the obvious place: declaring an ArrayList. Setting one up is quite different to how you\u2019d declare an array, because it uses the Java List interface.<br><\/p>\n\n\n\n<p>Open up a Java file and paste in the following code into your main class:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();<\/pre><\/div>\n\n\n\n<p>We\u2019ve just created an array list called <code>songs<\/code>. <code>String<\/code> refers to the type of data that will be stored in our array and ArrayList refers to the type of object we want to create.<br><\/p>\n\n\n\n<p>We\u2019ve got to import ArrayList into our code because it comes from the Java <code>util<\/code> library.<br><\/p>\n\n\n\n<p>It\u2019s worth noting that you cannot create array lists using primitive data types. If you want to declare an array of integers, for instance, you can\u2019t use the primitive <code>int<\/code> type; you\u2019d need to use the Integer class.<br><\/p>\n\n\n\n<p>Notice that we didn\u2019t have to specify how many values our ArrayList needs to store. That\u2019s because <code>ArrayLists<\/code> are dynamic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Add Elements to an ArrayList<\/h2>\n\n\n\n<p>The add() method lets you add a single element into your list. Let\u2019s say that we want to add in two songs to our <code>songs<\/code> array list: Love Me Do and Help! (which are both by The Beatles).<br><\/p>\n\n\n\n<p>Open up a new Java file and write in the following code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nclass Main {\n\tpublic static void main(String[] args) {\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();\n\t\tsongs.add(\"Love Me Do\");\n\t\tsongs.add(\"Help!\");\n\t\tSystem.out.println(\"Songs: \" + songs);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns: Songs: [Love Me Do, Help!]<br><\/p>\n\n\n\n<p>Like arrays, items in an <code>ArrayList<\/code> are given their own index numbers. This is because items in an ArrayList are ordered and the numbers tell our program in which order each item in our list should appear. If needed, you can specify the index position to which you want to add an item:<br><\/p>\n\n\n\n<p><code>songs.add(0, \u201cLove Me Do\u201d);<br><\/code><\/p>\n\n\n\n<p>This will add the entry \u201cLove Me Do\u201d at index position 0 to our <code>songs<\/code> list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Initialize an ArrayList<\/h2>\n\n\n\n<p>When you declare an array, you can initialize it directly by specifying the values that you want to assign to that array. <code>ArrayLists<\/code> don\u2019t work in this way. You\u2019ve got to use a special method called asList() from the Arrays class to initialize an <code>ArrayList. asList() <\/code>returns an array as a list that can be read by the ArrayList class.<br><\/p>\n\n\n\n<p>You may want to initialize an ArrayList with values if you\u2019ve already got a few values that you want to add to your list.<br><\/p>\n\n\n\n<p>You could use a for loop to add each item individually. However, that approach is more complex to set up and less efficient than initializing the list with values using <code>asList()<\/code>.<br><\/p>\n\n\n\n<p>Let\u2019s get started by importing the libraries we are going to use in our code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nimport java.util.Arrays;\n<\/pre><\/div>\n\n\n\n<p>We\u2019ll then write a class which initialized our songs ArrayList with two values:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\n\tpublic static void main(String[] args) {\n\t\tArrayList&lt;String&gt; songs = new ArrayList(Arrays.asList(\"Love Me Do\", \"Help!\"));\n\t\tSystem.out.println(\"Songs: \" + songs);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>In this code, we\u2019ve declared an <code>ArrayList<\/code> that can store string values. We\u2019ve used asList() to instruct our code to initialize our array list with two default values, which are the same Beatles songs that we added in our last example.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Retrieve an Item from an ArrayList<\/h2>\n\n\n\n<p>The ArrayList class comes with a handy method called <code>get()<\/code> that allows you to access the elements of an array list. To use this method, you&#8217;ve got to specify the index position of the element that you want to access.<\/p>\n\n\n\n<p>Consider this example:<br><br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nclass Main {\n\tpublic static void main(String[] args) {\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();\n\t\tsongs.add(\"Love Me Do\");\n\t\tsongs.add(\"Help!\");\n\t\tSystem.out.println(\"Second song: \" + songs.get(1));\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>In this code, we\u2019ve created an array list and added two values. We\u2019ve then used<code> songs.get(1)<\/code> to retrieve the song at the index position 1 in our list. Our code returns:<br><\/p>\n\n\n\n<p>Second song: Help!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Update an ArrayList<\/h2>\n\n\n\n<p>Updating an array list is as easy as adding elements to the list. There\u2019s a built-in method called <code>set() <\/code>that you can use to change the value stored in a list. Consider the following code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nclass Main {\n\tpublic static void main(String[] args) {\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();\n\t\tsongs.add(\"Love Me Do\");\n\t\tsongs.add(\"Help!\");\n\t\tSystem.out.println(\"Songs: \" + songs);\n\t\tsongs.set(1, \"Come Together\");\n\t\tSystem.out.println(\"Songs: \" + songs);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p>Songs: [Love Me Do, Help!]<\/p>\n\n\n\n<p>Songs: [Love Me Do, Come Together]<br><\/p>\n\n\n\n<p>In our code, we\u2019ve added two values \u2013 \u201cLove Me Do\u201d and \u201cHelp!\u201d \u2013 to our list. We\u2019ve then changed the item with the index position 1 to \u201cCome Together\u201d. This replaces \u201cHelp!\u201d with \u201cCome Together\u201d in our list. When we print out our list at the end of the program, we can see that it has been revised.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove an Element from an ArrayList<\/h2>\n\n\n\n<p>Elements don\u2019t have to stay in an ArrayList forever. You can remove an element using the <code>remove() <\/code>method at any time. What an easy method name to remember!<\/p>\n\n\n\n<p>Consider this example:<br><br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nclass Main {\n\tpublic static void main(String[] args) {\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();\n\t\tsongs.add(\"Love Me Do\");\n\t\tsongs.add(\"Help!\");\n\t\tSystem.out.println(\"Songs: \" + songs);\n\t\tString removed = songs.remove(0);\n\t\tSystem.out.println(\"Songs: \" + songs);\n\t\tSystem.out.println(removed);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>In this example, we add two items to our array list. We then remove the item with the index position 0. Our code returns:<br><\/p>\n\n\n\n<p>Songs: [Love Me Do, Help!]<\/p>\n\n\n\n<p>Songs: [Help!]<\/p>\n\n\n\n<p>Love Me Do<br><\/p>\n\n\n\n<p>We\u2019ve just removed <code>Love Me Do<\/code> from our array list. The <code>remove()<\/code> method returns the name of the item that has been removed, which we assigned to the variable <code>removed<\/code>. We printed out the value of this variable to the console at the end of our program.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Iterate Through an ArrayList<\/h2>\n\n\n\n<p>What if you want to loop through an ArrayList? You can do that using either a for loop or a for-each loop, depending on your preference.<br><\/p>\n\n\n\n<p>Let\u2019s say that we want to print out all the Beatles songs in our list to the console, with each value appearing on a new line. We could do so using the following code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nclass Main {\n\tpublic static void main(String[] args) {\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();\n\t\tsongs.add(\"Love Me Do\");\n\t\tsongs.add(\"Help!\");\n\t\tfor (int i = 0; i &lt; songs.size(); i++) {\n\t\t\tSystem.out.println(songs.get(i));\n\t\t}\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>In this program, we\u2019ve used a for loop to iterate through every item in our array list. For each item in the array list, we print it out to the console on its own line. This loop continues until every item in our list has been printed to the console.<br><\/p>\n\n\n\n<p>Notice that we\u2019ve used a method called <code>songs.size() <\/code>in this program. The size() method tells us how many values are stored in our array list.<br><\/p>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p>Love Me Do<\/p>\n\n\n\n<p>Help!<br><\/p>\n\n\n\n<p>Similarly, you can use a for-each loop to iterate through an array list. This is because for-each loops support iterating through any iterable object. Consider the following example:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.ArrayList;\nclass Main {\n\tpublic static void main(String[] args) {\nArrayList&lt;String&gt; songs = new ArrayList&lt;&gt;();\n\t\tsongs.add(\"Love Me Do\");\n\t\tsongs.add(\"Help!\");\n\t\tfor (String song : songs) {\n\t\t\tSystem.out.println(song);\n\t\t}\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>This program is very similar in both structure and purpose; it prints out all the values in our <code>songs<\/code> array list to the console. The difference is that we\u2019ve used a for-each loop to iterate through each value.<br><\/p>\n\n\n\n<p>You may opt to use a <code>for-each<\/code> loop instead of a <code>for<\/code> loop because it is easier to read a for-each loop, but both methods work effectively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Java ArrayList class allows you to define arrays which can store multiple values without being told how many values to store upfront.<br><\/p>\n\n\n\n<p>We\u2019ve only scratched the surface of using ArrayLists in Java. To learn more, you may want to view the following tutorials:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/careerkarma.com\/blog\/java-arraylist-to-array\/\">ArrayList to Array conversion<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/careerkarma.com\/blog\/java-initialize-arraylist\/\">How to initialize an ArrayList<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/careerkarma.com\/blog\/java-sort-arraylist\/\">How to sort an ArrayList<\/a><\/li>\n<\/ul>\n\n\n\n<p>Now you no longer have to worry about what you\u2019ll do if you don\u2019t know how many values an array will need to store. You\u2019ll be able to use ArrayList to solve this problem!<br><\/p>\n","protected":false},"excerpt":{"rendered":"Are you tired of having to declare the size of an array before you can use it? You\u2019re not the only one, as it\u2019s not always convenient to have to define how many values an array should store before you can start adding values to that array. That\u2019s where our helpful friend, the Java ArrayList,&hellip;","protected":false},"author":240,"featured_media":19089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-19088","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>ArrayList Java: A Beginner\u2019s Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The ArrayList class allows you to define resizable arrays in Java. On Career Karma, learn how to use the ArrayList class.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ArrayList Java: A Beginner\u2019s Guide\" \/>\n<meta property=\"og:description\" content=\"The ArrayList class allows you to define resizable arrays in Java. On Career Karma, learn how to use the ArrayList class.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-07T01:01:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:38:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"ArrayList Java: A Beginner\u2019s Guide\",\"datePublished\":\"2020-07-07T01:01:29+00:00\",\"dateModified\":\"2023-12-01T11:38:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\"},\"wordCount\":1366,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\",\"name\":\"ArrayList Java: A Beginner\u2019s Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg\",\"datePublished\":\"2020-07-07T01:01:29+00:00\",\"dateModified\":\"2023-12-01T11:38:56+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The ArrayList class allows you to define resizable arrays in Java. On Career Karma, learn how to use the ArrayList class.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/arraylist-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/arraylist-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/careerkarma.com\/blog\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"ArrayList Java: A Beginner\u2019s Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"ArrayList Java: A Beginner\u2019s Guide | Career Karma","description":"The ArrayList class allows you to define resizable arrays in Java. On Career Karma, learn how to use the ArrayList class.","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:\/\/careerkarma.com\/blog\/arraylist-java\/","og_locale":"en_US","og_type":"article","og_title":"ArrayList Java: A Beginner\u2019s Guide","og_description":"The ArrayList class allows you to define resizable arrays in Java. On Career Karma, learn how to use the ArrayList class.","og_url":"https:\/\/careerkarma.com\/blog\/arraylist-java\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-07T01:01:29+00:00","article_modified_time":"2023-12-01T11:38:56+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"ArrayList Java: A Beginner\u2019s Guide","datePublished":"2020-07-07T01:01:29+00:00","dateModified":"2023-12-01T11:38:56+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/"},"wordCount":1366,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/arraylist-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/","url":"https:\/\/careerkarma.com\/blog\/arraylist-java\/","name":"ArrayList Java: A Beginner\u2019s Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg","datePublished":"2020-07-07T01:01:29+00:00","dateModified":"2023-12-01T11:38:56+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The ArrayList class allows you to define resizable arrays in Java. On Career Karma, learn how to use the ArrayList class.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/arraylist-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/person-working-remotely-3987066.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/arraylist-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"ArrayList Java: A Beginner\u2019s Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=19088"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19088\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19089"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}