Let’s watch this video to find out more about the other data types besides the string data type.
A string variable can be seen as a ‘string’ of characters or a sequence of characters. It can contain many characters, as long as it is surrounded by “double quotation marks“.
If you were to forget the double quotation marks, you would get an error (shown by the red underline).
A char (short for character) can store unicode or single characters like ‘A’. This means that it can store values with only one letter or symbol.
When using a char in code, you need to put your value in single quotes, like ‘B’ or ‘d’.
If you were to add more than one character or forget the single quotation marks in a char, you would get an error.
An int (short for integer) can store both positive and negative numbers.
An integer value takes up the memory space of 4 bytes. It can only store numbers.
If we were to use letters in an int variable, we would get an error.
A double can store decimal values. It takes up the memory space of 8 bytes. You need to use a full stop (.) to create the decimal and not a comma (,).
If we were to use a comma to create our decimal, we would get an error.
A bool (short for boolean) can only store values as true or false. This takes up the memory space of 2 bytes.
A boolean can only take a true or false value. If we were to use “yes” or “no” as a value, we would get an error.