Initializing variables

Edit on Github instead

Java is a strongly typed programming language. This means that every variable must have a data type associated with it. For example, a variable could be declared as one of the eight primitive data types: A byte, short, int, float, double, char, or bool.

You can think of a variable like a container. When we declare variables in Java, we attach a Label to the container. To declare a variable in Java, all that is needed is the data type followed by the variable name:

int thisIsMyIntegerVariable;

In the above example, a variable called "thisIsMyIntegerVariable" has been declared with a data type int. The line ends in a semi-colon. The semi-colon tells the Java compiler that the declaration is complete.

Suggest changes

Related links

URL Topic Source