Skip to Content
Java 8 Pocket Guide
book

Java 8 Pocket Guide

by Robert Liguori, Patricia Liguori
April 2014
Intermediate to advanced
242 pages
3h 21m
English
O'Reilly Media, Inc.
Content preview from Java 8 Pocket Guide

Chapter 4. Reference Types

Reference types hold references to objects and provide a means to access those objects stored somewhere in memory. The memory locations are irrelevant to programmers. All reference types are a subclass of type java.lang.Object.

Table 4-1 lists the five Java reference types.

Table 4-1. Reference types
Reference typeBrief description

Annotation

Provides a way to associate metadata (data about data) with program elements.

Array

Provides a fixed-size data structure that stores data elements of the same type.

Class

Designed to provide inheritance, polymorphism, and encapsulation. Usually models something in the real world and consists of a set of values that holds data and a set of methods that operates on the data.

Enumeration

A reference for a set of objects that represents a related set of choices.

Interface

Provides a public API and is “implemented” by Java classes.

Comparing Reference Types to Primitive Types

There are two type categories in Java: reference types and primitive types. Table 4-2 shows some of the key comparisons between them. See Chapter 3 for more details.

Table 4-2. Reference types compared to primitive types
Reference typesPrimitive types

Unlimited number of reference types, as they are defined by the user.

Consists of boolean and numeric types: char, byte, short, int, long, float, and double.

Memory location stores a reference to the data.

Memory location stores actual data held by the primitive type.

When a reference type is assigned to another reference ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Spring MVC Beginner's Guide

Spring MVC Beginner's Guide

Amuthan Ganeshan
C# 7.0 Pocket Reference

C# 7.0 Pocket Reference

Joseph Albahari, Ben Albahari

Publisher Resources

ISBN: 9781491901083Errata