Comp 110 References vs. Values


Variables that are simple types (int, boolean, double, char) actually hold their values. What this means is that when you declare a variable with this type you are declaring a space in memory to hold a single variable with that type. When you assign a value to a variable, that value is copied into the variable's space in memory. 


On the other hand, variables cannot store arrays or objects. They simply take up too much space. So, instead of holding the value like for simple types, it holds a reference to another space in your computer's memory that can store all the information. It's kind of like holding an address in memory. When you assign to a variable, you are copying the address of the space in memory where that information is held.