Chapter 6 - Java for Beginners Course

Introduction

Up until chapter 5 we haven’t defined or used a lot of interactions between the objects we’ve created and we’ve only created a handful of objects in our examples.

This of course has been helpful to introduce the concepts we’ve covered so far.

However, in most projects you’ll encounter, you’ll be handling more than a few objects and objects will interact with each other in different ways.

It is also important to understand some behaviors that the JVM and the Java libraries use/expect us to provide, and to understand some behaviors provided by the compiler for classes that come from the Java library.

In this chapter we cover these base object interactions and behaviors, including:

  1. Object casting and type comparison

  2. Object equality and hash codes

  3. Object String representation

  4. Introduction to garbage collection

  5. Comparing objects (less than, equals or greater than)

  6. Primitive Wrapper types and Autoboxing

Chapter 7 will introduce data structures that allow us to handle collections of objects for our applications.

Code in GitHub

Get the code for this tutorial using the links below.

Project Repo
Download code for this step
Dependencies

This is a list of recommended tutorials or courses that might be useful before starting this one.

Contents
Welcome to the Course!
Course Introduction
Chapter 1 - Building Blocks
Quick introduction to Java Variables Classes And Objects Class Example - Defining a class Object Examples - Creating instances Java Application Example - Running our first app Accessing class members - The dot operator Packages - Organizing the code
Chapter 2 - Primitives and Operators
Primitives Arithmetic Operators Assignment Operator Unary Operators Equality and Relational Operators Conditional Operators
Chapter 3 - Statements and Control Flow
Expressions Statements If-Then Statement If-Then-Else Statement More If Statements Switch Statement While and Do-While Statements For Statement Branching Statements Exception Handling
Chapter 4 - Code Example
Example Project - A Simple Vending Machine Adding money Delivering Items Giving Change
Chapter 5 - Classes and Interfaces
Introduction Access Level Modifiers Class Declaration - Class, Methods and Fields Class Declaration - Constructors Inheritance Basics Inheritance - Constructors Inheritance - Methods and Fields Polymorphism Abstract Classes and Methods Interfaces Static Class Members Class Composition Final Classes and Class Members Generic Classes
Chapter 6 - Base Object Behaviors
Introduction Type Comparison Type Casting Object Equality - The Contract Object Equality - Common Pitfalls Object String Representation Garbage Collection Object Comparison Primitive Wrappers and Autoboxing
Chapter 7 - Data Structures
Introduction Arrays - Declaration and Creation Arrays - Basic Operations Core Collection Interfaces List and ArrayList - Basic Operations ArrayList Internals Introduction to Hash Tables Map and HashMap - Basic Operations Set and HashSet - Basic Operations
Chapter 8 - Anonymous classes and lambdas
Introduction Filtering a List Anonymous Classes Lambdas Built-in Functional Interfaces
Chapter 9 - Streams
Introduction Creating Streams Intermediate Operations Terminal Operations