Declaration is the process of reserving a portion in main memory (RAM) for storing the contents of a variable. In many high-level computer languages, the programmer must write a specific statement to reserve that portion in the RAM. In most cases, they even need to specify the variable type so that the compiler or the interpreter knows exactly how much space to reserve.
Here are some examples showing how variables are declared in different high-level computer languages.
Declaration Statement | High-level Computer Language |
Dim sum as Integer | Visual Basic |
int sum; | Java, C#, C++, and many more |
sum: Integer; | Pascal, Delphi |
var sum; | Javascript |