What are Variables?
Variables are things that hold a value. It could be letters or words.
The Int Variable
There are different types of variables in Java. The int variable always has to be a number.
For example, if you want to say the variable number stands for 84, the piece of code below shows how to write it.
int number = 84;
Int is the type of variable. Number is the name of the variable, and it holds the value of 84.
The Char Variable
Char stands for character. The char variable always has to be a single letter.
For example, it could be a movie rating. If you want to say that the rating of a movie is G, you use char.
char movieRating = ‘G’
Char is the type of variable. movieRating is the name, and it holds the value of G.
The String Variable
The String variable is always a word or many words.
String myString = “Hello World!”
String is the type of variable. myString is the name, and it holds the value of Hello World!.
Variables are used in many programs and will be very useful to you in any type of programming.