From the course: Oracle Java Certification: 1. Data Types

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Reference types

Reference types - Java Tutorial

From the course: Oracle Java Certification: 1. Data Types

Start my 1-month free trial

Reference types

- [Instructor] Java has two categories of data types. Primitive types and object reference types. Variables of primitive types are named storage units that actually store the primitive values. For example, the variables a, b, c on the left of the diagram, they represent the value they hold during program execution. In other words, the variable name is synonymous with the value it holds. So we can modify those values directly through the variable names. When a value is assigned from one variable to another, the value gets copied. Object reference variables, on the other hand, stores references to objects. Variables a, b, c on the right are assigned the same object. But they don't store three copies of the same object. They store three copies of the reference to the same object. When we assign one reference variable to another, the reference value, not the object, gets copied. Let's look at some examples. In this example, we declare an integer object reference variable A and a printed…

Contents