concept null in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide.
b. class EJavaGuru will print null.
The array declaration only creates a variable that refers to null, as shown in figure 7.5.
Figure 7.5 Array declaration creates a variable that refers to null.
![]()
Also, you can’t remove array positions. For an array of objects, you can set a position to the value null, but it doesn’t remove the array position:
String[] strArray = new String[] {"Autumn", "Summer", #1 "Spring", "Winter"}; #1 strArray[2] = null; #2 for (String val : strArray) #3 System.out.println(val); #3#1 creates an array of String and initializes it with four String values. #2 sets the value at array index 2 to null. #3 iterates over all the array elements. As shown in the following output, four (not three) values are printed:

This is an excerpt from Manning's book Modern Java in Action: Lambdas, streams, reactive and functional programming.
Common functional languages (SML, OCaml, Haskell) also provide further constructs to help programmers. One of these is avoiding null by explicit use of more descriptive data types. Tony Hoare, one of the giants of computer science, said this in a presentation at QCon London 2009:
Raise your hand if you ever got a NullPointerException during your life as a Java developer. Keep it up if this Exception is the one you encounter most frequently. Unfortunately, we can’t see you at this moment, but we believe that there’s a high probability that your hand is raised now. We also guess that you may be thinking something like “Yes, I agree. NullPointerExceptions are a pain for any Java developer, novice, or expert. But there’s not much we can do about them, because this is the price we pay to use such a convenient, and maybe unavoidable, construct as null references.” This feeling is common in the (imperative) programming world; nevertheless, it may not be the whole truth and is more likely a bias with solid historical roots.
British computer scientist Tony Hoare introduced null references back in 1965 while designing ALGOL W, one of the first typed programming languages with heap-allocated records, later saying that he did so “simply because it was so easy to implement.” Despite his goal “to ensure that all use of references could be absolutely safe, with checking performed automatically by the compiler,” he decided to make an exception for null references because he thought that they were the most convenient way to model the absence of a value. After many years, he regretted this decision, calling it “my billion-dollar mistake.” We’ve all seen the effect. We examine a field of an object, perhaps to determine whether its value is one of two expected forms, only to find that we’re examining not an object but a null pointer that promptly raises that annoying NullPointerException.
In reality, Hoare’s statement could underestimate the costs incurred by millions of developers fixing bugs caused by null references in the past 50 years. Indeed, the vast majority of the languages[1] created in recent decades, including Java, have been built with the same design decision, maybe for reasons of compatibility with older languages or (more probably), as Hoare states, “simply because it was so easy to implement.” We start by showing you a simple example of the problems with null.
1Notable exceptions include most typed functional languages, such as Haskell and ML. These languages include algebraic data types that allow data types to be expressed succinctly, including explicit specification of whether special values such as null are to be included on a type-by-type basis.

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.
Purpose: Identify the difference between an array element that isn’t initialized and an array element that doesn’t exist. A pictorial representation of a multidimensional array is quick to draw, and you can easily refer to its nonexistent or null array elements. This concept is shown in figure A.3.
Because String is a class, you can assign null to it, as shown in the next example:
The array declaration only creates a variable that refers to null, as shown in figure 4.23.
Figure 4.23. Array declaration creates a variable that refers to null.
![]()
String multiStrArr[][] = new String[][]{ {"A", "B"}, null, {"Jan", "Feb", "Mar"}, };
The equals method implements an equivalence relation on non-null object references:
It is reflexive: for any non-null reference value x, x.equals(x) should return true. It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals() comparisons on the objects is modified. For any non-null reference value x, x.equals(null) should return false.

This is an excerpt from Manning's book Functional Programming in Java: How functional techniques improve your Java programs.
The first one can’t throw any exceptions because x can’t be null (you’ll see why in chapter 5), and method first can’t throw an exception either.
The second and third functions can’t throw a NullPointerException because you’ve ensured that a Tuple couldn’t be constructed with null arguments. (See chapter 1 for the code of the Tuple class.) Figure 2.4 shows these functions in their anonymous form.
In Java, a variable is a pointer to a value. Variables may be created null (static and instance variables are created null by default), and they may then be changed to point to values. They can even be changed again to point to null if data is removed.
static Function<List<Integer>, Double> mean = xs -> { if (xs.isEmpty()) { return null; } else { return xs.foldLeft(0.0, x -> y -> x + y) / xs.length(); } };

This is an excerpt from Manning's book Java 8 in Action: Lambdas, streams, and functional-style programming.
Common functional languages (SML, OCaml, Haskell) also provide further constructs to help programmers. One of these is avoiding null by explicit use of more descriptive data types. Indeed, Tony Hoare, one of the giants of computer science, said in a presentation at QCon London 2009:
Raise your hand if you ever got a NullPointerException during your life as a Java developer. Keep it up if this is the Exception you encounter most frequently. Unfortunately, we can’t see you at this moment, but we believe there’s a very high probability that your hand is raised now. We also guess you may possibly be thinking something like “Yes, I agree, NullPointerExceptions are a pain for any Java developer, novice, or expert, but there’s not much we can do about them, because this is the price we pay to use such a convenient, and maybe unavoidable, construct as null references.” This is a common feeling in the (imperative) programming world; nevertheless, it may not be the whole truth but more likely a bias with solid historical roots.
A British computer scientist named Tony Hoare introduced null references back in 1965 while designing ALGOL W, one of the first typed programming languages with heap-allocated records, “simply because it was so easy to implement.” Despite his goal “to ensure that all use of references could be absolutely safe, with checking performed automatically by the compiler,” he decided to make an exception for null references, because he thought this was the most convenient way to model the absence of a value. After many years he regretted this decision, calling it “my billion-dollar mistake.” We’ve all seen the effect—we examine a field of an object, perhaps to determine whether its value is one of two expected forms, only to instead find we’re examining not an object but a null pointer that promptly raises that annoying NullPointerException.
In reality, Hoare’s statement could underestimate the costs incurred by millions of developers fixing bugs caused by null references in the last 50 years. Indeed, the vast majority of the languages[1] created in recent decades, including Java, have been built with the same design decision, maybe for reasons of compatibility with older languages, or more probably, as Hoare states, “simply because it was so easy to implement.” Let’s start by looking at a simple example to understand the problems with null.
1 Notable exceptions include most typed functional languages, such as Haskell and ML; these include algebraic data types that allow data types to be succinctly expressed, including explicit specification of whether special values such as null are to be included on a type-by-type basis.
Listing 10.2. Null-safe attempt 1: deep doubts
public String getCarInsuranceName(Person person) { if (person != null) { #1 Car car = person.getCar(); if (car != null) { #1 Insurance insurance = car.getInsurance(); if (insurance != null) { #1 return insurance.getName(); } } } return "Unknown"; } #1: Each null check increases the nesting level of the remaining part of the invocation chain.