-
Book Overview & Buying
-
Table Of Contents
The Java Workshop
By :
We presented the concept of null within Java in a previous chapter. As you may recall, null is the value that is implicitly assigned to an object upon creation, that is, unless you assign a different value to it. Related to null is the NullPointerException value. This is a very common event that can and will happen to you for a variety of reasons. In this section, we will highlight some of the most common scenarios of this in an effort to introduce you to a different way of thinking when dealing with any type of exception in your code.
In Example01, we examined the process of trying to perform operations on an object that was pointing to null. Let's look at some other possible cases:
public class Example04 {
public static void main(String[] args) {
String vehicleType = null;
String vehicle = "car";
&...
Change the font size
Change margin width
Change background colour