A variable is a symbolic representation denoting a value or expression.
Variables can be contrasted with constants, which are known and unchanging.
A variable is usually named by an identifier, but it can be anonymous and can be associated with another variable.
C++ |
In C++ the format of a variable or constant declaration statement is as follows: [const][ modifiers] type identifier[ = expression][ , identifier[ = expression][ , ...]] ; where
|
---|
When working with closely related data of the same type and scope, it is often convenient to store them together in a data structure instead of in individual variables. The most common data structure is the array. Arrays are fixed-length structures for storing multiple values of the same type.
In Java, an array is declared in the same way any variable is declared. The type is the type of the elements contained in the array. The [] notation is used to indicate that the variable is an array. For example:
int single ;
int[] multiple ;
In this example single is a single integer variable and multiple is an array of integer variables.
example | GCC C++ | |
Borland C++ Compiler | ||
Java | ||
home | Home Page |