What’s the difference between primitive and reference types?

From book OCA JAVA SE 7

Just as men and women are fundamentally different (according to John
Gray, author of Men Are from Mars, Women Are from Venus), primitive
variables and object reference variables differ from each other in
multiple ways. The basic difference is that primitive variables store
the actual values, whereas reference variables store the addresses of
the objects they refer to. Let’s assume that a class Person is
already defined. If you create an int variable a, and an object
reference variable person, they will store their values in memory as
shown in figure 2.13.

int a = 77;
Person person = new Person();

enter image description here

Leave a Comment