Variables

by 14:15 0 comments

In basic algebra, variables are symbols that can represent values in formulas.

For example the variable in the formula f(x)=x2+2 can represent any number value.

Similarly, variables in computer program are symbols for arbitrary data.


Variables in Java have a type.

The type defines what kinds of values a variable is allowed to store.

Think of a variable’s type as the size or shape of the empty box.

The variable x in f(x)=x2+2 is implicitly a number.
If is a symbol representing the word “Fish”, the formula doesn’t make sense.  

Think of variables as an empty box that you can put
 values in.
We can label the box with a name like “Box X” and 
re-use it many times.
Can perform tasks on the box without caring about 
what’s inside:
“Move Box X to Shelf A”
“Put item Z in box”
“Open Box X”
“Remove contents from Box X”

Unknown

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 comments:

Post a Comment