An in-depth look into the reference concept
 
 

You may have learned in CS170 that the following variable definition clause:

    ClassName  varName;                          

 Examples:

    BankAccount  Mary;
    String       h;

defines a reference variable

What exactly does such variable contain ??

What is a reference ?
 

References used in Computer Science
 

How can we reference a location in memory ?

Example:

How can we reference a location in memory ?

Another reference example:

We have actually seen a reference previously !!!

The value stored in the program counter (PC) is a reference (= memory address):

We have actually seen a reference previously !!!

The value stored in the program counter (PC) is a reference (= memory address):

So the PC points to the next instruction code in memory !!!