Data is foundational in programming and is classified into different types to indicate how it can be interpreted, compiled, and used in software. For the most part, data types are categorized into two groups: primitive or composite values.
Primitive Data Types
Primitive data types are the building blocks for any variable or data structure in a program. They usually contain a single value such as a character, byte, or digit. A few examples of primitive types are listed below:
|String||Sequences of characters surrounded by single quotes (
|Boolean||Holds a logical value of
Composite Data Types
Composite data types can be composed of multiple of the same or different primitive data types, sometimes referred to as members, elements, or items. The following are examples of well known composite types:
|Array||Collections of values that are usually defined with
|Object||Groups of related data that are usually organized as property-value pairs.|
|Class||Templates for objects that may contain properties or methods.|
Other Common Data Types
Data types have gone beyond just composites and primitives and include ones with unique qualities such as the following:
|Undefined||Represents a value that has not yet been defined.|
|Function||Depending on the language, functions can be utilized as variables and arguments for other functions.|
|Void||Sets a function to have side effects but return no specific result. Common in C-based languages.|
|Complex Number||Type representation for complex numbers, sometimes with
Data Types in Different Languages
The way that data types look and work may vary from one programming language to another:
- Represents the logical values of true and false.
- Represents many numeric values.
- Stores a sequence of indexed characters that can be of any length and is contained within a pair of single or double quotes.
- Denotes functions that have side effects but do not return an actual result.
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.