Section 1 - Variables


Let’s say that memory location 1000 contains the value 4. We wish for memory location 1004 to contain the value 5.




We could operate directly on the memory locations.


                MEM[1000] = 4

                MEM[1004] = MEM[1000] + 1


But wouldn’t it be easier to give memory location 1000 the name A, and memory location 1004 the name B, then refer to these locations as simply A and B.


A = 4

B = A + 1


A and B defined above are variables. A variable is name given to a memory location. When we write Java programs, we will use variables to which Java will assign different memory locations. As programmers, we need to be aware of this, but we don’t really need to know what addresses correspond to the variables we create.






Copyright ©2017 by Ralph Lecessi Incorporated. All rights reserved.