Basic Array Implementation with Read, Insert and Update in Five Programming Language’s [Java, JavaScript, Python, C, and Dart] for Beginners
By: Md. Nayan Sarder
Tags: Arrays, Dart, Java, Data Structures, Programming

Array

An array is a data structure that contains a group of elements and the elements are all same data type. Also, Array is a Non-Primitive data type. The array index started from 0 (zero) most of the learners getting confused here. So we should remember the array index started from 0 (zero). If the array size is 10 the array index is 0 to 9. There are two types of array one-dimensional and multi-dimensional.

In this article we see one-dimensional array implementation:

1. Java Array Implementation

There are many ways to implement an array in Java based on which type of data you want to store because we already know an array store only one type of data element. In Java, you can implement an array statically and dynamically.

The static implement of an array is declaration and instantiation with one line like:

dataType arrayName = {“element1”, “element2”, “element3”,…………}; int numericArray = {10, 15, 20, 25, 30, 80};

The dynamic implement is first declaring an array then initialization with data element like:

dataType[] arrayName = new dataType[arraySize];

For the most widely used implementation and operation in Java. Please see below code example:

Java Array Example

2. C Array Implementation

C is a Structured Programming language. We already know how to implement an array, insert elements, view elements and update elements in Java. As we know java is an Object Oriented Programming language and C is a Structured Programming language. For declaring an array in C you must always tell the size of the array when declare.

Declare an array in C (dataType arrayName[arraySize];). See the below coding example for details about C array:

C Array Example

3. Python Array Implementation

Python is an interpreted programming language. Python programming is one of the most successful programming languages that mostly uses for AI, Machine learning, data science, web and software development. Python has many awesome data-structure

Now array implementation in python. At first, we need to import array as like

import array as arr

Then call the array function using arr and create a python array. As like

arr.array(‘i’, [5, 10, 15, 20, 25])

Here array function always takes two arguments first one is the data type code and the second one is the array data. I provide all the data type code below.

Data type code for python array (Credit: programiz)

Now, See the below code for a better understanding of Python array.

Python Array Example

Here I am trying to see you how to declare a python array and insert data update data and get data from the array. But in array in python is not to much use. The alternative is List Data-structure. List are more flexible to use than an array in python language. want to know more about the list search on Google.

4. JavaScript Array Implementation

JavaScript is an interpreted language. Also known as the scripting programming language. JavaScript is widely used for Web development It has well-known framework NodeJs, ReactJs, and VueJs.

Now JavaScript array is a single variable that store all elements. You can declare Script array in two ways like:

1. var arrayName = [1,2,3] 2. var arrayName = new Array();

Now for inserting, viewing and updating element on JavaScript array follow the below code:

JavaScript Array Example

JavaScript array has many methods like push(), pop() and toString() and many more. But for the basic operation, you just need the above implementation.

5. Dart Array Implementation

Dart is a cross-platform programming language build by google. It’s used for built Mobile, Web, and Desktop based software. Dart has an awesome framework Flutter for built apps.

In dart programming, there is no data-structure named array it’s named List. Using the List you totally fell like an array. Dart array or list is almost like JavaScript Array. Let’s see the dart array:

Dart Array Example

Dart List has many methods to handle operations, array sorting, etc. If you are interested in the dart programming you can see their official doc

Conclusions

This is my first blog about programming. I am trying here to show array implementation in five programming language Java, C, Python, JavaScript, and Dart for beginners. If you found any problem in this article or you want to contact with me, please send an email here smd.nayan69@gmail.com

Thank You and Happy Coding 😍