The int, boolean, and char are fundamental data types of Java that we will see again later in the course.

Another important feature of Java (and of many programming languages) is the ability to store values using variables.

  1. A variable stores a value.

  2. In Java, all variables must have a specified data type.

We can assign a variable to a specified data type, like this:

int myLuckyNumber = 7;

The variable myLuckyNumber now stores the value 7 as an int type.

A semicolon ; is also used to end all Java single code statements. We will cover statements that should not end in a semicolon later in this course.



Set the int variable myNumber equal to the value 42.


Set the boolean variable isFun equal to true.


Set the char variable movieRating equal to 'A'.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?