Learn
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.
A variable stores a value.
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.
Instructions
1.
Set the int
variable myNumber
equal to the value 42
.
2.
Set the boolean
variable isFun
equal to true
.
3.
Set the char
variable movieRating
equal to 'A'
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.