Introduction
In this lab, you will learn how to safely handle Integer
wrapper objects in Java, specifically focusing on checking if they are null
. Unlike primitive int
, Integer
is an object that can hold a null
reference, and failing to check for null
can lead to common NullPointerException
errors.
Through practical examples, you will explore the basic == null
check, combine null checks with value comparisons, and finally, learn how to leverage the Optional
class for more robust and expressive null handling in your Java code.