top of page

How to Object

You struggle to understand objects, references, primitive types and what exactly is the difference between them? Then this quickguide is for you.


Memory is where the program and all its variables is stored. Imagine for the purpose of this course that memory is made up of small blocks which all have the same size and can contain any value that fits inside of them. We will refer to the size of a box as 64 bits. This means that it can store a sequence of 0s and 1s of at most length 64.

Eprog Ref (4).png

Primitive Types

In Java everything is based on primitive types and concepts like arrays, classes, methods using them. There are eight primitive types overall. Primitive types use different amounts of space in the memory blocks. However the remaining space is assumed to not be used and instead left empty. Primitive types are constraint by these space limitations.


What if it does not fit?

Objects in contrast to primitive types can be much larger than any primitive types, they themselves can contain a multitude of primitive type values. We cannot make the memory blocks larger hence we use multiple memory blocks to store the entire object in memory. We then use a reference to the group of memory blocks inside of a reference variable to allow an object to be found. A reference variable does not contain the object, it instead contains a reference (or address) to the location of the object in memory. 


Memory during Runtime 

All primitive type variables will store values inside memory and all reference variables will store references to parts of memory where the object is stored. This fills up the blocks in memory. As these are limited at some point one will reach a limit where no more space is available. For the moment you will not have to worry about that though.

Eprog Ref (11).png
bottom of page