Java Programming, Programming Fundamentals

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

One Comment

Comments are closed.

%d bloggers like this: