10 Data Types (With Definitions and Examples)

Updated June 24, 2022

When coding across programming languages, there are many common data types that software developers can use. These data types can determine how much memory a computer needs to process the code, how long it might take to load certain features and what functions a program might perform.

Learning about the basic types of data for coding can help you better understand these processes. In this article, we define common data types in programming and provide examples of each.

Related: How To Write Code in 6 Steps

What is a data type?

A data type is an attribute of a piece of data that tells a device how the end-user might interact with the data. You can also think of them as categorizations that different coding programs might combine in order to execute certain functions. Most programming languages including C++ and Java use the same basic data types.

Related: What Is Java? (With FAQs)

10 data types

Each programming language uses a different combination of data types. Some of these types include:

1. Integer

Integer data types often represent whole numbers in programming. An integer's value moves from one integer to another without acknowledging fractional numbers in between. The number of digits can vary based on the device, and some programming languages may allow negative values.

2. Character

In coding, alphabet letters denote characters. Programmers might represent these data types as (CHAR) or (VARGCHAR), and they can be single characters or a string of letters. Characters are usually fixed-length figures that default to 1 octet—an 8-bit unit of digital information—but can increase to 65,000 octets.

Related: Learning How To Code

3. Date

This data type stores a calendar date with other programming information. Dates are typically a combination of integers or numerical figures. Since these are typically integer values, some programs can store basic mathematical operations like days elapsed since certain events or days away from an upcoming event.

4. Floating point (real)

Floating-point data types represent fractional numbers in programming. There are two main floating-point data types, which vary depending on the number of allowable values in the string:

  • Float: A data type that typically allows up to seven points after a decimal.

  • Double: A data type that allows up to 15 points after a decimal.

5. Long

Long data types are often 32- or 64-bit integers in code. Sometimes, these can represent integers with 20 digits in either direction, positive or negative. Programmers use an ampersand to indicate the data type is a long variable.

6. Short

Similar to the long data type, a short is a variable integer. Programmers represent these as whole numbers, and they can be positive or negative. Sometimes a short data type is a single integer.

7. String

A string data type is a combination of characters that can be either constant or variable. This often incorporates a sequence of character data types that result in specific commands depending on the programming language. Strings can include both upper and lowercase letters, numbers and punctuation.

8. Boolean

Boolean data is what programmers use to show logic in code. It's typically one of two values—true or false—intended to clarify conditional statements. These can be responses to "if/when" scenarios, where code indicates if a user performs a certain action. When this happens, the Boolean data directs the program's response, which determines the next code in the sequence.

9. Nothing

The nothing data type shows that a code has no value. This might indicate that a code is missing, the programmer started the code incorrectly or that there were values that defy the intended logic. It's also called the "nullable type."

10. Void

Similar to the nothing type, the void type contains a value that the code cannot process. Void data types tell a user that the code can't return a response. Programmers might use or encounter the void data type in early system testing when there are no responses programmed yet for future steps.

Data type examples

Data types can vary based on size, length and use depending on the coding language. Here are some examples of the data types listed above that you might encounter when programming:


Integers are digits that account for whole numbers only. Some integer examples include:

  • 425

  • 65

  • 9


Characters are letters or other figures that programmers might combine in a string. Examples of characters include:

  • a

  • ^

  • !


Programmers can include individual dates, ranges or differences in their code. Some examples might be:

  • 2009-09-15

  • 1998-11-30 09:45:87



Long data types are whole numbers, both positive and negative, that have many place values. Examples include:

  • -398,741,129,664,271

  • 9,000,000,125,356,546


Short data types can be up to several integers, but they are always less than long data. Examples include:

  • -27,400

  • 5,428

  • 17

Floating point (real)

Float data types might look like this:

  • float num1 = 1.45E2

  • float num2 = 9.34567

Similar but often longer in length, an example of the floating-point double might be:

  • double num2 = 1.87358497267482791E+222

  • double num2 = 3.198728764857268945

The floating-point double type can provide more accurate values, but it also may require additional memory to process.


Strings are a combination of figures that includes letters and punctuation. In some code, this might look like this:

  • String a = new String("Open")

  • String b = new String("The door")

  • String c = new String("Say Hello!")

These can be independent commands, or they can work together.


Boolean data can help guide the logic in a code. Here are some examples of how you might use this:

  • bool baseballIsBest = false;

  • bool footballIsBest = true;

Depending on the program, the code may direct the end-user to different screens based on their selection.

Related: How To Use Boolean Search Strings To Find Great Resumes


Nothing means a code has no value, but the programmer coded something other than the digit 0. This is often "Null," "NaN" or "Nothing" in code. An example of this is:

  • Dim option = Nothing

  • Program.WriteWords(x Is Nothing)


The void data type in coding functions as an indicator that code might not have a function or a response yet. This might appear as:

  • int function_name (void)

Please note that none of the products mentioned in this article are affiliated with Indeed.

Explore more articles

  • A Complete Guide to Memo Writing (With Tips and Examples)
  • Market Needs: What They Are and 9 Strategies To Define Them
  • How To Write a Letter To Human Resources (HR)
  • 21 Places To Donate Office Supplies
  • How To Find Different in Excel: Methods and Tips for Formatting
  • How To Write an Artist Bio (With Tips and Examples)
  • What Are Interfaces? (With Definition and Examples)
  • How Often Should You Get a Raise? (With Tips)
  • How To Calculate Days in Inventory (With 3 Examples)
  • 4 Types of Narrative Styles (With Examples)
  • 6 Top Leadership Training Programs in 2023
  • 11 Common Types of Figurative Language (With Examples)