{"id":41487,"date":"2024-03-06T12:33:00","date_gmt":"2024-03-06T07:03:00","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/"},"modified":"2025-01-13T17:06:05","modified_gmt":"2025-01-13T11:36:05","slug":"what-is-an-array-learn-more-in-one-read","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/","title":{"rendered":"What is an Array? Learn more in one read!"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"what-is-an-array\"><strong>What is an Array?<\/strong><\/h2>\n\n\n\n<p>An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number.<\/p>\n\n\n\n<p>For example, if we want to store the marks scored by a student in 5 subjects, then there\u2019s no need to define individual variables for each subject. Rather, we can define an array that will store the data elements at contiguous memory locations.<\/p>\n\n\n\n<p>Array marks<strong>[5]<\/strong> define the marks scored by a student in <strong>5<\/strong> different subjects where each subject's marks are located at a particular location in the array, i.e., marks<strong>[0] <\/strong>denote the marks scored in the first subject, <strong>marks[1]<\/strong> denotes the marks scored in <strong>2nd <\/strong>subject and so on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"different-types-of-arrays\">Different Types Of Arrays<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Single-Dimensional Arrays (1-D)<\/strong><\/li>\n\n\n\n<li><strong>Multi-Dimensional Arrays<\/strong><\/li>\n\n\n\n<li><strong>Three-Dimensional (3-D) Arrays<\/strong><\/li>\n\n\n\n<li><strong>Dynamic Arrays<\/strong><\/li>\n\n\n\n<li><strong>Character Arrays<\/strong><\/li>\n<\/ul>\n\n\n\n<p>To learn how different arrays in C work, check out our blog \"<a href=\"https:\/\/www.mygreatlearning.com\/blog\/types-of-array-in-c\/\">Types of Array in C.<\/a>\"<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-need-of-using-array\">What Is The <strong>Need of using Array?<\/strong><\/h2>\n\n\n\n<p>In programming, most of the cases need to store a large amount of data of a similar type. We need to define numerous variables to store such a huge amount of data. <br><br>While writing the programs, it would be very tough to memorize all variable names. Instead, it is better to define an array and store all the elements in it.<\/p>\n\n\n\n<p>The following example illustrates how an array can be used while writing a code-<\/p>\n\n\n\n<p>In the following example, we have given marks to a student in 5 different subjects. The aim is to calculate the average of a student's marks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-array\"><strong>Using Array <\/strong><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include&lt;stdio.h&gt;\nvoid main()\n{\n        \tint subject1 = 40, subject2 = 52, subject3 = 47, subject4 = 70, subject5= 67;\n        \tfloat avg = (subject1 + subject2 + subject3 + subject4 + subject5)\/5;\n        \tprintf(avg);\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"without-using-array\"><strong>Without Using Array<\/strong><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include&lt;stdio.h&gt;\nvoid main()\n{\n        \tint subject1 = 40, subject2 = 52, subject3 = 47, subject4 = 70, subject5= 67;\n        \tfloat avg = (subject1 + subject2 + subject3 + subject4 + subject5)\/5;\n        \tprintf(avg);\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"what-are-the-types-of-indexing-in-array\">What Are The <strong>Types Of Indexing In Array<\/strong>?<\/h3>\n\n\n\n<p>\u00b7<strong> 0 (Zero Based Indexing)-&nbsp; <\/strong>The first element of the array refers to index 0.<\/p>\n\n\n\n<p>\u00b7 <strong>1 (One Based Indexing)-&nbsp;<\/strong> The first element of the array refers to index 1.<\/p>\n\n\n\n<p>\u00b7 <strong>n (n Based Indexing)-<\/strong> The base index of an array can be chosen as per requirement.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0.png\"><img decoding=\"async\" width=\"538\" height=\"258\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0.png\" alt=\"What is an Array\" class=\"wp-image-41530\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0.png 538w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-300x144.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-150x72.png 150w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-the-complexity-of-array-operations\"><strong>What Is The Complexity of Array Operations? <\/strong><\/h3>\n\n\n\n<p><strong>Time Complexity<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>Algorithm<\/td><td>Average case<\/td><td>Worst case<\/td><\/tr><tr><td>Access<\/td><td>O(1)<\/td><td>O(1)<\/td><\/tr><tr><td>Search<\/td><td>O(n)<\/td><td>O(n)<\/td><\/tr><tr><td>Insertion<\/td><td>O(n)<\/td><td>O(n)<\/td><\/tr><tr><td>Deletion<\/td><td>O(n)<\/td><td>O(n)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The space complexity of an array for the worst case is <strong>O(n)<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-are-the-advantages-of-array\"><strong>What Are The Advantages of Array?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Arrays represent multiple data elements of the same type using a single name.<\/li>\n\n\n\n<li>Accessing or searching an element in an array is easy by using the index number.<\/li>\n\n\n\n<li>&nbsp;An array can be traversed easily just by incrementing the index by 1.<\/li>\n\n\n\n<li>Arrays allocate memory in contiguous memory locations for all its data elements.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-access-elements-in-an-array\">How To <strong>Access Elements in an Array<\/strong>?<\/h3>\n\n\n\n<p>To access any element of an array, we need the following details:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Base Address of array.<\/li>\n\n\n\n<li>Size of an element in bytes.<\/li>\n\n\n\n<li>Which type of indexing array follows.<\/li>\n<\/ol>\n\n\n\n<p>The address of any element of a 1D array can be calculated by using the below-given formula:<\/p>\n\n\n\n<p>Byte address of an element A[i] = base address + size * (i - first index)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-pass-array-to-a-function\">How To <strong>Pass Array To a Function<\/strong>?<\/h3>\n\n\n\n<p>As mentioned earlier, the name of an array represents the address of the first element of the array. The elements of an array can be traversed just by using the base address.<\/p>\n\n\n\n<p>The below example illustrates how an array can be passed to a function.<\/p>\n\n\n\n<p>The below program defines a function named total, which accepts an array as an argument. This function calculates the sum of all the elements of the array.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include&lt;stdio.h&gt;\nint total(int&#x5B;]);\nvoid main()\n{\n\tint arr&#x5B;5] = {0,1,2,3,4};\n\tint sum = total(arr);\n\tprintf(\u201c%d\u201d,sum);\n}\nint total(int arr&#x5B;])\n{\n\tint sum=0;\n\tint i;\n\tfor(i=0; i&lt;5; i++)\n\t{\n\t\tsum = sum + arr&#x5B;i];\n\t}\n\treturn sum;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-2d-array\">What is <strong>2D Array<\/strong>?<\/h3>\n\n\n\n<p>2 Dimensional arrays are often defined as an array of arrays. A 2D array is also called a matrix. A matrix can be depicted as a table of rows and columns.<\/p>\n\n\n\n<p><p data-ghostkit-sr=\"zoom-up\"><strong><em><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/array-in-c-in-hindi\">Also, now you can learn Arrays in C Programming in Hindi<\/a><\/em><\/strong><\/p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-declare-2d-array\"><strong>How To Declare 2D Array?<\/strong><\/h3>\n\n\n\n<p>The syntax of declaring a 2D array is very much similar to that of an 1D array.<\/p>\n\n\n\n<p><strong>Syntax -&nbsp;<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nint arr&#x5B;max_rows]&#x5B;max_columns];\n<\/pre><\/div>\n\n\n<p>It produces data structure as shown below:<\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/1.png\"><img decoding=\"async\" width=\"538\" height=\"258\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/1.png\" alt=\"What is an Array\" class=\"wp-image-41531\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/1.png 538w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/1-300x144.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/1-150x72.png 150w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-access-data-in-a-2d-array\"><strong>How to access data in a 2D array?<\/strong><\/h3>\n\n\n\n<p>As in a one-dimensional array, data can be accessed by using only an index, and similarly, in a two-dimensional array, we can access the cells individually by using the indices of the cells. There are two indices attached to a single cell, one is its row number, and the other one is its column number.<\/p>\n\n\n\n<p>Syntax to store the value stored in any particular cell of an array -&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nint x = a&#x5B;i]&#x5B;j];\n<\/pre><\/div>\n\n\n<p>Here i and j are the row and column indices, respectively.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"initializing-2d-array\"><strong>Initializing 2D array -&nbsp;<\/strong><\/h3>\n\n\n\n<p>When we declare a one-dimensional array, there\u2019s no need to specify the size of the array, but it\u2019s not the same for a two-dimensional array. For a 2D array, we need to specify at least the row size, i.e., the second dimension.<\/p>\n\n\n\n<p>Syntax to declare 2D array -&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nint arr&#x5B;2]&#x5B;2] = {1,2,3,4}\n<\/pre><\/div>\n\n\n<p>The number of elements present in a 2D array will always be equal to (<strong>number of rows * number of columns<\/strong>).<\/p>\n\n\n\n<p><strong>Example :<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"c-program-to-store-users-data-into-a-2d-array\"><strong>C program to store user\u2019s data into a 2D array<\/strong><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include&lt;stdio.h&gt;\nvoid main()\n{\n\tint arr&#x5B;4]&#x5B;4],i,j;\n\tfor (i=0; i&lt;4; i++)\n\t{\n\t\tfor (j=0; j&lt;4; j++)\n\t\t{\n\t\t\tprintf(\u201cEnter value for arr&#x5B;%d]&#x5B;%d]: \u201c i,j);\n\t\t\tscanf(\u201c%d\u201d,&amp;arr&#x5B;i]&#x5B;j]);\n\t\t}\n\t}\n}\n\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"java-program-to-store-users-data-into-a-2d-array\">&nbsp;<strong>Java program to store user\u2019s data into a 2D array<\/strong><\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nimport java.util.Scanner;\npublicclass ArrayTwoD {\npublicstaticvoid main(String&#x5B;] args) {\nint&#x5B;]&#x5B;] arr = newint&#x5B;4]&#x5B;4];\nScanner sc = new Scanner(System.in);\nfor(int i=0; i&lt;4; i++)\n{\nfor(int j=0; j&lt;4;j++)\n{\n\tSystem.out.print(\u201cEnter Data\u201d);\n\tarr&#x5B;i]&#x5B;j] = sc.nextInt();\n\tSystem.out.println();\n}\n}\n}\n}\n\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"mapping-2d-to-1d-array\"><strong>Mapping 2D to 1D array -&nbsp;<\/strong><\/h4>\n\n\n\n<p>2D arrays are mainly created to implement a database table that look alike data structure. Whilst in computer memory, the storage technique for 2D arrays is similar to that of one-dimensional arrays.<\/p>\n\n\n\n<p>The size of a 2D array is always equivalent to the product of the number of rows and the number of columns present in the array. Thus, we need to map two-dimensional arrays to one-dimensional arrays so as to store them in the memory.<\/p>\n\n\n\n<p>A 3 X 3 2D array is shown in the image below.&nbsp;<\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-1.png\"><img decoding=\"async\" width=\"538\" height=\"258\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-1.png\" alt=\"What is an Array\" class=\"wp-image-41535\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-1.png 538w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-1-300x144.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/0-1-150x72.png 150w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p><strong>There are 2 main techniques to map a two-dimensional array to one-dimensional array<\/strong>.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Row Major Ordering <\/strong><\/li>\n<\/ol>\n\n\n\n<p>In row-major ordering, all the rows of the two-dimensional array are stored in a contiguous manner in the memory. Considering the array shown within the above image, its memory allocation according to the row-major order technique is shown below.<\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/2.png\"><img decoding=\"async\" width=\"538\" height=\"258\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/2.png\" alt=\"What is an Array\" class=\"wp-image-41536\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/2.png 538w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/2-300x144.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/2-150x72.png 150w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>First, we insert elements of the 1st row of the 2D array into the memory, followed by the elements of the 2nd row and so on.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>Column Major Ordering <\/strong><\/li>\n<\/ol>\n\n\n\n<p>In column-major ordering, all the columns of the two-dimensional array are stored in a contiguous manner in the memory. Considering the array shown in the above image, its memory allocation consistent with the column-major order technique is shown below.<\/p>\n\n\n<figure class=\"wp-block-image size-large is-resized zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/3.png\"><img decoding=\"async\" width=\"538\" height=\"258\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/3.png\" alt=\"What is an Array\" class=\"wp-image-41539\" style=\"width:538px;height:auto\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/3.png 538w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/3-300x144.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/08\/3-150x72.png 150w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>First, we insert elements of the 1st column of the 2D array into the memory, followed by the elements of the 2nd column, and so on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Learn everything about arrays and broaden your knowledge with a Postgraduate Program in Software Development designed by industry experts. This program covers everything from programming basics to databases and includes multiple coding challenges. It prepares you for top tech and product companies. Advance your skills with the&nbsp; <a href=\"https:\/\/www.mygreatlearning.com\/advanced-software-engineering-course-iit-madras\">PG Program in Software Development<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faqs\">FAQs<\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1715140423124\"><strong class=\"schema-faq-question\"><strong>What is an array?<\/strong><br\/><\/strong> <p class=\"schema-faq-answer\">An array is a data structure used to store multiple elements of the same type under a single variable name. It organizes data so that a related set of values can be easily sorted or searched.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1715140439175\"><strong class=\"schema-faq-question\"><strong>How do you access elements in an array?<\/strong><br\/><\/strong> <p class=\"schema-faq-answer\">You can access elements in an array by referring to the index number associated with each element. The index of the first element is 0, the second element is 1, and so on.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1715140456404\"><strong class=\"schema-faq-question\"><strong>Can arrays store different types of data?<\/strong><\/strong> <p class=\"schema-faq-answer\">Typically, arrays are meant to store elements of the same type. However, in languages like JavaScript, arrays can store elements of different types because they are implemented as objects\u200b\u200b.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1715140473122\"><strong class=\"schema-faq-question\"><strong>What are multidimensional arrays?<\/strong><br\/><\/strong> <p class=\"schema-faq-answer\">Multidimensional arrays are arrays that contain other arrays as their elements. These are used to represent more complex structures like matrices\u200b.<br\/><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1715140497277\"><strong class=\"schema-faq-question\"><strong>What are the advantages of using arrays?<\/strong><br\/><\/strong> <p class=\"schema-faq-answer\">Arrays allow fast access to elements as you can directly jump to any element using its index. This makes reading data very efficient. They also simplify the management of large datasets by allowing operations on multiple items at once\u200b\u200b.<br\/><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1715140507789\"><strong class=\"schema-faq-question\"><strong>What are the disadvantages of using arrays?<\/strong><br\/><\/strong> <p class=\"schema-faq-answer\">Modifying arrays can be inefficient, especially if you need to add or remove elements in the middle of the array because this requires shifting elements to maintain order. Also, in some programming languages, arrays have a fixed size once they are created, which limits their flexibility\u200b.<br\/><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1715140528196\"><strong class=\"schema-faq-question\"><strong>How do you initialize an array in Java?<\/strong><br\/><\/strong> <p class=\"schema-faq-answer\">In Java, you can initialize an array either by specifying the size and then filling it, or by directly filling it with elements at the time of declaration. For example, int[] myArray = new int[10]; initializes an array with space for 10 integers, whereas int[] myArray = {1, 2, 3}; initializes and fills the array at the same time\u200b\u200b.<br\/><\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is an Array? An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number. For example, if we want to store the marks scored by a student in 5 subjects, then [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":39006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[],"content_type":[],"class_list":["post-41487","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>What is an Array? Types of Array | Great Learning<\/title>\n<meta name=\"description\" content=\"What is an Array: An array is a collection of similar data elements stored at contiguous memory locations that represent datatypes\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is an Array? Learn more in one read!\" \/>\n<meta property=\"og:description\" content=\"What is an Array: An array is a collection of similar data elements stored at contiguous memory locations that represent datatypes\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-06T07:03:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-13T11:36:05+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1622\" \/>\n\t<meta property=\"og:image:height\" content=\"647\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"What is an Array? Learn more in one read!\",\"datePublished\":\"2024-03-06T07:03:00+00:00\",\"dateModified\":\"2025-01-13T11:36:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/\"},\"wordCount\":1450,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/iStock-1250153350.jpeg\",\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/\",\"name\":\"What is an Array? Types of Array | Great Learning\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/iStock-1250153350.jpeg\",\"datePublished\":\"2024-03-06T07:03:00+00:00\",\"dateModified\":\"2025-01-13T11:36:05+00:00\",\"description\":\"What is an Array: An array is a collection of similar data elements stored at contiguous memory locations that represent datatypes\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140423124\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140439175\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140456404\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140473122\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140497277\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140507789\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140528196\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/iStock-1250153350.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/iStock-1250153350.jpeg\",\"width\":1622,\"height\":647,\"caption\":\"news\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"What is an Array? Learn more in one read!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140423124\",\"position\":1,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140423124\",\"name\":\"What is an array?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"An array is a data structure used to store multiple elements of the same type under a single variable name. It organizes data so that a related set of values can be easily sorted or searched.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140439175\",\"position\":2,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140439175\",\"name\":\"How do you access elements in an array?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"You can access elements in an array by referring to the index number associated with each element. The index of the first element is 0, the second element is 1, and so on.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140456404\",\"position\":3,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140456404\",\"name\":\"Can arrays store different types of data?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Typically, arrays are meant to store elements of the same type. However, in languages like JavaScript, arrays can store elements of different types because they are implemented as objects\u200b\u200b.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140473122\",\"position\":4,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140473122\",\"name\":\"What are multidimensional arrays?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Multidimensional arrays are arrays that contain other arrays as their elements. These are used to represent more complex structures like matrices\u200b.<br\\\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140497277\",\"position\":5,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140497277\",\"name\":\"What are the advantages of using arrays?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Arrays allow fast access to elements as you can directly jump to any element using its index. This makes reading data very efficient. They also simplify the management of large datasets by allowing operations on multiple items at once\u200b\u200b.<br\\\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140507789\",\"position\":6,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140507789\",\"name\":\"What are the disadvantages of using arrays?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Modifying arrays can be inefficient, especially if you need to add or remove elements in the middle of the array because this requires shifting elements to maintain order. Also, in some programming languages, arrays have a fixed size once they are created, which limits their flexibility\u200b.<br\\\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140528196\",\"position\":7,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/what-is-an-array-learn-more-in-one-read\\\/#faq-question-1715140528196\",\"name\":\"How do you initialize an array in Java?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"In Java, you can initialize an array either by specifying the size and then filling it, or by directly filling it with elements at the time of declaration. For example, int[] myArray = new int[10]; initializes an array with space for 10 integers, whereas int[] myArray = {1, 2, 3}; initializes and fills the array at the same time\u200b\u200b.<br\\\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What is an Array? Types of Array | Great Learning","description":"What is an Array: An array is a collection of similar data elements stored at contiguous memory locations that represent datatypes","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:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/","og_locale":"en_US","og_type":"article","og_title":"What is an Array? Learn more in one read!","og_description":"What is an Array: An array is a collection of similar data elements stored at contiguous memory locations that represent datatypes","og_url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2024-03-06T07:03:00+00:00","article_modified_time":"2025-01-13T11:36:05+00:00","og_image":[{"width":1622,"height":647,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"What is an Array? Learn more in one read!","datePublished":"2024-03-06T07:03:00+00:00","dateModified":"2025-01-13T11:36:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/"},"wordCount":1450,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg","articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/","url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/","name":"What is an Array? Types of Array | Great Learning","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg","datePublished":"2024-03-06T07:03:00+00:00","dateModified":"2025-01-13T11:36:05+00:00","description":"What is an Array: An array is a collection of similar data elements stored at contiguous memory locations that represent datatypes","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140423124"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140439175"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140456404"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140473122"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140497277"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140507789"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140528196"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg","width":1622,"height":647,"caption":"news"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"What is an Array? Learn more in one read!"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140423124","position":1,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140423124","name":"What is an array?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"An array is a data structure used to store multiple elements of the same type under a single variable name. It organizes data so that a related set of values can be easily sorted or searched.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140439175","position":2,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140439175","name":"How do you access elements in an array?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"You can access elements in an array by referring to the index number associated with each element. The index of the first element is 0, the second element is 1, and so on.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140456404","position":3,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140456404","name":"Can arrays store different types of data?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Typically, arrays are meant to store elements of the same type. However, in languages like JavaScript, arrays can store elements of different types because they are implemented as objects\u200b\u200b.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140473122","position":4,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140473122","name":"What are multidimensional arrays?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Multidimensional arrays are arrays that contain other arrays as their elements. These are used to represent more complex structures like matrices\u200b.<br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140497277","position":5,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140497277","name":"What are the advantages of using arrays?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Arrays allow fast access to elements as you can directly jump to any element using its index. This makes reading data very efficient. They also simplify the management of large datasets by allowing operations on multiple items at once\u200b\u200b.<br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140507789","position":6,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140507789","name":"What are the disadvantages of using arrays?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Modifying arrays can be inefficient, especially if you need to add or remove elements in the middle of the array because this requires shifting elements to maintain order. Also, in some programming languages, arrays have a fixed size once they are created, which limits their flexibility\u200b.<br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140528196","position":7,"url":"https:\/\/www.mygreatlearning.com\/blog\/what-is-an-array-learn-more-in-one-read\/#faq-question-1715140528196","name":"How do you initialize an array in Java?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"In Java, you can initialize an array either by specifying the size and then filling it, or by directly filling it with elements at the time of declaration. For example, int[] myArray = new int[10]; initializes an array with space for 10 integers, whereas int[] myArray = {1, 2, 3}; initializes and fills the array at the same time\u200b\u200b.<br\/>","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg",1622,647,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-150x150.jpeg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-300x120.jpeg",300,120,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-768x306.jpeg",768,306,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-1024x408.jpeg",1024,408,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-1536x613.jpeg",1536,613,true],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350.jpeg",1622,647,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-640x647.jpeg",640,647,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-96x96.jpeg",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/07\/iStock-1250153350-150x60.jpeg",150,60,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"What is an Array? An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number. For example, if we want to store the marks scored by a student in 5 subjects, then&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/41487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=41487"}],"version-history":[{"count":31,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/41487\/revisions"}],"predecessor-version":[{"id":99129,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/41487\/revisions\/99129"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/39006"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=41487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=41487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=41487"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=41487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}