Java Variables
In this lesson, we will learn how to work with Java Variables. Variables in Java are a reserved area allocated in memory. It is a container which holds value. Each variable is assigned a type, which is known as data type. We will also work around the types of Java Variables, including Local, Instance and Class Variable.
The reserved area set for the variable stRank as shown below. Here, the variable is assigned a value 5. Also, you can see, we need a datatype to declare a variable. The int data type is used below.
Declare Variables in Java
As in the above figure, variables are declared by adding a data type, with the variable name.
Here are some examples:
0 comments:
Post a Comment