{"id":13181,"date":"2020-03-11T19:55:16","date_gmt":"2020-03-12T02:55:16","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13181"},"modified":"2023-12-01T02:31:27","modified_gmt":"2023-12-01T10:31:27","slug":"java-vector","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-vector\/","title":{"rendered":"How to Use Vector in Java"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/k2XGraK9PV-THVlJHwlEmxs8lzQ2hU6WQJUByGyf1VyuZrJqFqVEhnbqUo6vlGGc8C23skH9lYup9DoTiPhKD7P1ortpxDTyJ-3tbbl5Ro3RvVEMaYYulcF_-a3C7hWZpBOV7wFq\" alt=\"\"\/><\/figure>\n\n\n\n<p>In Java, there are a wide range of classes used to store particular types of data. Each class has its own features and the class used to store a type of data determines how it can be accessed and manipulated.<br><\/p>\n\n\n\n<p>One of the most important classes in Java is the Vector class. Vector is an implementation of the List interface and is used to create resizable arrays.<br><\/p>\n\n\n\n<p>This tutorial will walk through, with reference to examples, how to use the Vector class in Java to create resizable arrays. In addition, this tutorial will discuss how Vector compares to the ArrayList class, which is very similar to Vector.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java List Interface<\/h2>\n\n\n\n<p>The List interface is used to create ordered sets of data in Java. For instance, a List may store a list of shoes sold in a shoe store or a list of the names of every employee that works for a bank.<br><\/p>\n\n\n\n<p>However, since List is an interface, you cannot create an object from List. So, if you want to create a list, you need to use one of the classes that extend the List interface. These are: ArrayList, LinkedList, Vector, and Stack. This tutorial will focus on how you can use the Vector class to create a List object in Java.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Vector<\/h2>\n\n\n\n<p>Vector uses the List interface to create resizable arrays. To create a vector in Java, you can use the following syntax:<br><\/p>\n\n\n\n<p><code>Vector&lt;DataType&gt; vector_name = new Vector&lt;&gt;();<br><\/code><\/p>\n\n\n\n<p>Let\u2019s break this syntax down into its basic parts:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Vector<\/strong> tells our program we want to declare a vector.<\/li>\n\n\n\n<li><strong>DataType<\/strong> is the type of data our vector will store.<\/li>\n\n\n\n<li><strong>vector_name<\/strong> is the name of our vector.<\/li>\n\n\n\n<li><strong>new Vector&lt;&gt;();<\/strong> creates a new vector and assigns it to the <code>vector_name <\/code>variable.<\/li>\n<\/ul>\n\n\n\n<p>For instance, suppose we wanted to declare a vector that stores all the colors of lamps our department store sells. We could use this code to declare the vector:<br><\/p>\n\n\n\n<p><code>Vector&lt;String&gt; lamp_colors = new Vector&gt;?();<br><\/code><\/p>\n\n\n\n<p>Now we have a vector called<code> lamp_colors<\/code> which can store all the colors of lamps our department store sells.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Vector Methods<\/h2>\n\n\n\n<p>The Java Vector class provides a number of methods that are used to retrieve and manipulate the data stored in a vector. Let\u2019s break down a few of the most important methods offered by the Vector class.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Add Items to a Vector<\/h3>\n\n\n\n<p>There are three methods that are used to add items to vectors. The one you use will depend on how you want to add an item to a vector.<br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add Element to Vector<\/h4>\n\n\n\n<p>The <code>add() <\/code>method is used to add an element to a vector. The syntax for the <code>add() <\/code>method is:<br><\/p>\n\n\n\n<p><code>add(index, elementName);<br><\/code><\/p>\n\n\n\n<p>The <code>add() <\/code>method accepts two parameters:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>index<\/strong> is the index value at which the item you specify should be added to a vector.<\/li>\n\n\n\n<li><strong>elementName<\/strong> is the item you want to add to a vector.<\/li>\n<\/ul>\n\n\n\n<p>If you want to add an item to the end of a vector, the <code>index<\/code> parameter is not necessary.<br><\/p>\n\n\n\n<p>Suppose we are operating a department store chain and we are making a list of the colors in which a specific desk lamp is sold for our new furniture range. The manufacturer has just notified us that orange and blue lamps will accompany the next order, so we want to add orange and blue to our list of colors.<br><\/p>\n\n\n\n<p>We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Vector;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tVector&lt;String&gt; lamp_colors = new Vector&lt;&gt;();\n\t\t\n\t\tlamp_colors.add(\"Orange\");\n\t\tlamp_colors.add(\"Blue\");\n\t\tSystem.out.println(\"Vector: \" + lamp_colors);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>Vector: [Orange, Blue]<br><\/code><\/p>\n\n\n\n<p>As you can see, our code has added <code>Orange<\/code> and <code>Blue<\/code> to our <code>lamp_colors <\/code>vector.<br><\/p>\n\n\n\n<p>Suppose the manufacturer has just reached out to tell us that they are also going to deliver our gray lamps. We want to add gray lamps to the start of our list because we expect them to be more popular than other colors. We could do so using the example from above and adding this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Vector;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tVector&lt;String&gt; lamp_colors = new Vector&lt;&gt;();\n\t\t\n\t\tlamp_colors.add(\"Orange\");\n\t\tlamp_colors.add(\"Blue\");\nlamp_colors.add(0, \"Gray\");\n\t\tSystem.out.println(\"Vector: \" + lamp_colors);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>Vector: [Gray, Orange, Blue]<br><\/code><\/p>\n\n\n\n<p>In this example, we have used the <code>add() <\/code>method to add <code>Gray<\/code> to the <code>lamp_colors<\/code> vector. We specified the index parameter 0 in our code which tells <code>add()<\/code> to add the <code>Gray<\/code> item to the index position 0. In other words, we have added <code>Gray<\/code> to the start of our vector. Then we tell our program to print out the entire vector.<br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Merge Vectors<\/h4>\n\n\n\n<p>The <code>addAll()<\/code> method is used to add all elements from a vector to another vector.<br><\/p>\n\n\n\n<p>Suppose we have two lists: color range and lamp colors. We want to merge these two lists together because our lamp manufacturer has told us they will be able to manufacture lamps in every color in our color range. We could use the following code to merge these two vector lists together:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Vector;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tVector&lt;String&gt; color_range = new Vector&lt;&gt;();\n\t\tVector&lt;String&gt; lamp_colors = new Vector&lt;&gt;();\n\t\tcolor_range.add(\"Blue\");\n\t\tcolor_range.add(\"Black\");\n\t\tcolor_range.add(\"Gray\");\n\t\tcolor_range.add(\"Pink\");\n\t\tcolor_range.add(\"Orange\");\n\t\tlamp_colors.addAll(color_range);\n\t\tSystem.out.println(\"Color range: \" + color_range);\n\t\tSystem.out.println(\"Lamp colors: \" + lamp_colors);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Color range: [Blue, Black, Gray, Pink, Orange]\nLamp colors: [Blue, Black, Gray, Pink, Orange]<\/pre><\/div>\n\n\n\n<p>Our code first added the colors in our color range to the vector <code>color_range<\/code>. Then we used <code>addAll()<\/code> to add all colors from <code>color_range<\/code> to the <code>lamp_colors<\/code> vector. On the final lines in our code, we print out both the contents of <code>color_range<\/code> and <code>lamp_colors <\/code>to the console.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Retrieve Elements from a Vector<\/h3>\n\n\n\n<p>The <code>get()<\/code> method is used to retrieve a particular element from a vector. <code>get()<\/code> accepts one parameter: the index value of the item you want to retrieve.<br><\/p>\n\n\n\n<p>Suppose our list of lamp colors is stored in alphabetical order and we want to retrieve the first item in our list. We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Vector;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tVector&lt;String&gt; lamp_colors = new Vector&lt;&gt;();\nlamp_colors.add(\"Black\");\n\t\tlamp_colors.add(\"Blue\");\n\t\tlamp_colors.add(\"Gray\");\n\t\tlamp_colors.add(\"Orange\");\n\t\tlamp_colors.add(\"Pink\");\n\t\tString first_element = lamp_colors.get(0);\n\t\tSystem.out.println(\"First element in list: \" + first_element);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>First element in list: Black<br><\/code><\/p>\n\n\n\n<p>In our code, we use the <code>get() <\/code>method to retrieve the first item in the <code>lamp_colors<\/code> vector. We specify the index parameter 0, which tells our code to retrieve the first item in the vector, or in other words the item at the index position 0. Then, we print out the first element in the list to the console, preceded by the message <code>First element in list:<\/code>.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Remove Elements from a Vector<\/h3>\n\n\n\n<p>There are three methods which can be used to remove elements from a vector: <code>remove()<\/code>, <code>removeAll()<\/code>, and <code>clear().<\/code><br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Remove Single Element<\/h4>\n\n\n\n<p>The <code>remove()<\/code> method is used to remove a single element from a vector. <code>remove() a<\/code>ccepts one parameter: the index position of the element you want to remove from a vector.<br><\/p>\n\n\n\n<p>Let\u2019s return to the department store. Our manufacturer has notified us that they are no longer able to manufacture our orange lamps, and so we need to remove them from our list of colors in which our lamps are sold. We could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Vector;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tVector&lt;String&gt; lamp_colors = new Vector&lt;&gt;();\nlamp_colors.add(\"Black\");\n\t\tlamp_colors.add(\"Blue\");\n\t\tlamp_colors.add(\"Gray\");\n\t\tlamp_colors.add(\"Orange\");\n\t\tlamp_colors.add(\"Pink\");\n\t\tlamp_colors.remove(3);\n\t\tSystem.out.println(\"New color list: \" + lamp_colors);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>New color list: [Black, Blue, Gray, Pink]<br><\/code><\/p>\n\n\n\n<p>We have used the <code>remove()<\/code> method to remove the item at index position 3 in our list. In this case, the value of that item is <code>Orange<\/code>. Then we print out the revised color list to the console, preceded by the message <code>New color list:<\/code>.<br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Remove All Elements<\/h4>\n\n\n\n<p>The <code>removeAll()<\/code> and <code>clear()<\/code> methods are used to remove all elements from a list. Generally, using <code>clear() <\/code>is favored because it is more efficient, but you can also use the <code>removeAll()<\/code> method.<br><\/p>\n\n\n\n<p>Suppose the manufacturer has decided that they will no longer be able to manufacture our lamps because they are downsizing their operations. So, we will no longer be selling lamps until we find a new manufacturer. We could use the following list to remove all the colors of the lamps we sell:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Vector;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tVector&lt;String&gt; lamp_colors = new Vector&lt;&gt;();\nlamp_colors.add(\"Black\");\n\t\tlamp_colors.add(\"Blue\");\n\t\tlamp_colors.add(\"Gray\");\n\t\tlamp_colors.add(\"Orange\");\n\t\tlamp_colors.add(\"Pink\");\n\t\tlamp_colors.clear();\n\t\tSystem.out.println(\"New color list: \" + lamp_colors);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>New color list: []<br><\/code><\/p>\n\n\n\n<p>We have used the <code>clear() <\/code>method to remove all elements in the <code>lamp_colors<\/code> vector. Then, on the final line of our code, we printed out the phrase New color list: \u201c, followed by the empty vector.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Vector and ArrayList<\/h2>\n\n\n\n<p>Both ArrayList and Vector implement the Java list interface. These classes also provide the same methods. However, there are a few differences between the two classes.<br><\/p>\n\n\n\n<p>The main difference to note is that the Vector class is synchronized, which means that only one thread at a time can access the code. ArrayList, on the other hand, is unsynchronized, and so multiple threads can work on the list at the same time.&nbsp;<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Additional Vector Methods<\/h2>\n\n\n\n<p>In addition, there are a few other methods that can be used to manipulate the data stored within a vector. Here is a reference table with these methods:<br><\/p>\n\n\n\n<figure class=\"wp-block-table course-info-table\"><table><tbody><tr><td>Method Name<\/td><td>Description<\/td><\/tr><tr><td>contains()<\/td><td>Searches a vector for a specific value<\/td><\/tr><tr><td>iterator()<\/td><td>Iterates through a vector<\/td><\/tr><tr><td>set()<\/td><td>Changes an element in a vector<\/td><\/tr><tr><td>size()<\/td><td>Returns the length of a vector<\/td><\/tr><tr><td>toArray()<\/td><td>Converts a vector to an array<\/td><\/tr><tr><td>toString()<\/td><td>Converts a vector to a string<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Vector class is used in Java to store data using the List interface. For instance, a Vector may be used to store a list of products sold at a department store or a list of supplements available at a local drug store.<br><\/p>\n\n\n\n<p>This tutorial discussed the basics of the Java Vector class, how to create a vector, and the main difference between Vector and ArrayList. In addition, this tutorial walked through the main methods that can be used to retrieve and manipulate the contents of a vector, with reference to examples.<br><\/p>\n\n\n\n<p>Now you have the skills you need to start using the Vector class in Java like a pro!<\/p>\n","protected":false},"excerpt":{"rendered":"In Java, there are a wide range of classes used to store particular types of data. Each class has its own features and the class used to store a type of data determines how it can be accessed and manipulated. One of the most important classes in Java is the Vector class. Vector is an&hellip;","protected":false},"author":240,"featured_media":13182,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13181","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.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use Vector in Java: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The Java Vector class is used to create resizable arrays with the Java List interface. Learn more in this article.\" \/>\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\/java-vector\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Vector in Java\" \/>\n<meta property=\"og:description\" content=\"The Java Vector class is used to create resizable arrays with the Java List interface. Learn more in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-vector\/\" \/>\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-03-12T02:55:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:31:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-using-macbook-air-on-table-1181248-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Use Vector in Java\",\"datePublished\":\"2020-03-12T02:55:16+00:00\",\"dateModified\":\"2023-12-01T10:31:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/\"},\"wordCount\":1437,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/person-using-macbook-air-on-table-1181248-1.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/\",\"name\":\"How to Use Vector in Java: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/person-using-macbook-air-on-table-1181248-1.jpg\",\"datePublished\":\"2020-03-12T02:55:16+00:00\",\"dateModified\":\"2023-12-01T10:31:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Java Vector class is used to create resizable arrays with the Java List interface. Learn more in this article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/person-using-macbook-air-on-table-1181248-1.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/person-using-macbook-air-on-table-1181248-1.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-vector\\\/#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\":\"How to Use Vector in Java\"}]},{\"@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\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"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":"How to Use Vector in Java: A Step-By-Step Guide | Career Karma","description":"The Java Vector class is used to create resizable arrays with the Java List interface. Learn more in this article.","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\/java-vector\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Vector in Java","og_description":"The Java Vector class is used to create resizable arrays with the Java List interface. Learn more in this article.","og_url":"https:\/\/careerkarma.com\/blog\/java-vector\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-12T02:55:16+00:00","article_modified_time":"2023-12-01T10:31:27+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-using-macbook-air-on-table-1181248-1.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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-vector\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Use Vector in Java","datePublished":"2020-03-12T02:55:16+00:00","dateModified":"2023-12-01T10:31:27+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-vector\/"},"wordCount":1437,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-using-macbook-air-on-table-1181248-1.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-vector\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-vector\/","url":"https:\/\/careerkarma.com\/blog\/java-vector\/","name":"How to Use Vector in Java: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-using-macbook-air-on-table-1181248-1.jpg","datePublished":"2020-03-12T02:55:16+00:00","dateModified":"2023-12-01T10:31:27+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Java Vector class is used to create resizable arrays with the Java List interface. Learn more in this article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-vector\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-using-macbook-air-on-table-1181248-1.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-using-macbook-air-on-table-1181248-1.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-vector\/#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":"How to Use Vector in Java"}]},{"@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\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","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\/13181","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=13181"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13181\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13182"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}