FIT1051 Lecture Notes - Lecture 5: Memory Address
Week 5
Thursday, 22 March 2018
7:00 PM
Value and Reference Types
Apart from primitive data types, the only other types we have come across are class types. A class
such as a Person class as well as being a recipe of data items and methods to make Person objects is
also a data type. Objects instantiated from the Person class are referenced by variables with the type
Person. Actually given that data types define a memory storage format and classes define a unique
set of instance variables the connection is obvious.
All primitive data types are value types all other types are reference types.
Variables are just a programmer friendly name for memory address. Actual addresses are a
sequence of 64 1's and 0's. Java translates our friendly names back and forth from these cryptic
addresses as required.
Variables of value types are addresses of the values they store.
Variables of reference types are addresses of addresses of the values they store.
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
Apart from primitive data types, the only other types we have come across are class types. A class such as a person class as well as being a recipe of data items and methods to make person objects is also a data type. Objects instantiated from the person class are referenced by variables with the type. Actually given that data types define a memory storage format and classes define a unique set of instance variables the connection is obvious. All primitive data types are value types all other types are reference types. Variables are just a programmer friendly name for memory address. Actual addresses are a sequence of 64 1"s and 0"s. Java translates our friendly names back and forth from these cryptic addresses as required. Variables of value types are addresses of the values they store.