Arrays

Is an Array a Composite Data Type?

In most usage, an array is a composite data type. Learn what composite types are, how arrays fit, how records differ, and why the terms vary.

On this page
  1. The short answer
  2. What a composite data type is
  3. Why an array fits
  4. The other case: records and structs
  5. Terminology differences
  6. Language notes
  7. How it connects to primitive vs non primitive data types
  8. Quick check for an exam

The short answer

In most usage, yes. An array is a composite data type, because it is built from many values. Some sources are more specific and call it a homogeneous composite, since every element has the same type. The exact terms vary, so check the definitions your course uses.

What a composite data type is

A composite data type is a type assembled from other types. It bundles several values into one unit. The parts can be simple values, such as numbers and characters, or other composite types, which allows nesting.

Some sources call this kind of type an aggregate or a compound type. Those words are often used the same way, but some writers use aggregate more narrowly, for example to mean only arrays and lists.

Why an array fits

An array fits the definition because it groups many values under one name. Each element can be read or written through its index. In most typed languages, all elements share one type, which makes an array the simplest kind of composite.

For example, an array of integers is built from integer values. The array is a single object, but it contains many parts. That combination is the core of what makes a type composite.

The other case: records and structs

A record, or a struct in C, is also composite. The difference is that its fields can have different types. A record for a student might hold a name as a string, an age as an integer, and a grade as a floating-point number. Its parts are usually called fields rather than elements.

Records and arrays are often described as the two main shapes of composite types. An array is the homogeneous shape, and a record is the heterogeneous one. Many sources use the words record and structure interchangeably.

Terminology differences

Terminology varies across sources:

  • Composite is the main term in reference material on data types.
  • Aggregate can refer to the whole category, or only to homogeneous collections such as arrays and lists.
  • Compound is a close synonym that some sources use.

When a question uses one of these words, read the surrounding material to see which meaning is intended.

Language notes

Languages differ in how they handle arrays:

  • C arrays have one element type and a fixed size. C’s struct is the common composite for mixed field types.
  • Java arrays hold one element type and have a fixed length set when they are created.
  • Python has a list type that can mix element types, and a standard-library array module that stores values of one numeric type. Both fit the broad idea of a composite type, though the list is more flexible.

These descriptions are general. Check the documentation for your language for details.

How it connects to primitive vs non primitive data types

Primitive types are the basic built-in types, such as integers, floats, and characters. Composite types are built from them. Some courses use primitive and non-primitive instead of composite, so an array may be labeled non-primitive there. That is the same array, described with a different convention. Primitive vs non primitive data types covers that split in more detail.

Quick check for an exam

If a question asks whether an array is a composite data type, answer yes, say that it is built from many values, and name the homogeneous case. If the question uses another term, such as aggregate or compound, note that the terms overlap and explain the meaning you are using.

The complete guide to arrays

Is an Array a Data Structure?
Read the guide

Keep exploring

Guides from other topics

All topics →