Sobes.tech
Junior — Middle

Is an array a data structure with a fixed or changing size?

sobes.tech AI

Answer from AI

In Java, an array is a data structure with a fixed size. Once an array is created, its length cannot be changed. If you need to work with a collection of elements of variable size, you use classes from the collection framework, such as ArrayList.

int[] fixedArray = new int[5]; // size 5, cannot be changed

ArrayList<Integer> dynamicList = new ArrayList<>();
dynamicList.add(1); // size changes dynamically