These two days in the writing class of the judgment method, such as Ispeople (): Boolean, if the error returns null. An error occurs when the return type is Boolean.
After debugging, the return type is Boolean without error. A little puzzled. After finding the data, I found that I did not understand the object types and basic types of java.
Object type:
Example: Java.lang.Boolean wraps a base type Boolean in an object and contains only one field of type Boolean. In addition, this type provides a number of methods for Boolean and string conversions, and provides other constants and methods that are useful when dealing with Boolean.
Basic type: Or a built-in type, is a special type in Java that is different from a class. They are the most frequently used types in our programming.
Therefore, when the return type is a base type, the return value cannot have null because it is not an object. If the return type is Boolean, the return value must be true or false. However, when the return type is an object type, NULL can be returned because the object is nullable.
Note:
Basic types can be grouped into three categories, character type char, Boolean-type Boolean, and numeric type Byte, short, int, long, float, double. Numeric types can also be divided into integer type Byte, short, int, long, and floating-point type float, double. Numeric types in Java do not have unsigned, and their range of values is fixed and will not change as the machine hardware environment or operating system changes. In fact, there is another basic type Void in Java, which also has the corresponding wrapper class java.lang.Void, but we can't manipulate them directly.