Thursday , February 2 2023
Home / Java Programming / Static and Dynamic Arrays

Static and Dynamic Arrays

What is difference between Static and Dynamic Arrays:

Static simply means fixed and dynamic simply means having changing behavior. So in case of Static Arrays the maximum size of the arrays should be declared at the time of array creation. While the dynamic arrays can adapt the size on the fly. Thus the static arrays does not reallocate memory.

Some reasons to use arrays:

  1. Arrays are the guaranteed way to maximize the memory usage
  2. If you want to develop an application that uses add or remove operations then use a unsorted array, otherwise for the search / find operation to implement, select a sorted array.

Static Array Declaration:

One dimensional static integer array can be declared as:

int[ ] arrayName = {10, 20, 30, 40, 50};

The above statement will create and initialize one-dimensional static integer array.

index element / value
0 10
1 20
2 30
3 40
4 50

Check Also

Ayat No. 6 Explanation | Surah Fatiha | Ayat No. 6 With Tarjama Tafseer

Surah Al-Fatihah is the first Surah to be revealed in its entirety. It is also …

One comment

  1. Thanks Sir

Leave a Reply

%d bloggers like this: