Comp 110 Simple Data Types

Simple Data Types

There are three simple data types:

 number, string, boolean

These data types are known as primitives. These store single pieces of data and are the building blocks of everything we will create in code. Primitive data types can be combined together to construct more complicated compound data types. More information on this can be found here.


The number type is used for numerical data, which includes positive, negative, decimal, and whole numbers.

Examples of number literals:



The string type is used for textual data. All strings are enclosed in double quotes. Anything inside of these quotes is part of the string.

Examples of string literals:

"*Go heels!*"

Note: "110" is treated as a string since it's in double quotes. This is NOT the same as the number 110.


The boolean type is only used for true and false. A boolean must be either true or false.

Examples of boolean literals:


More examples:

import { print } from "introcs";

print("UNC"); // "UNC" is a string literal. This prints UNC
print(2018); // 2018 is a number. This prints 2018
print(true); // true is a boolean. This prints true
print("true"); // "true" is a string since it is in double quotes. This prints true
print("1789"); // "1789" is a string since it's in double quotes. This prints 1789