Javatpoint Logo
Javatpoint Logo

Java null reserved word

In Java, null is a reserved word for literal values. It seems like a keyword, but actually, it is a literal similar to true and false.

Points to remember

  • It is case-sensitive.
  • It is a value of the reference variable.
  • The access to a null reference generates a NullPointerException.
  • It is not allowed to pass null as a value to call the methods that contain any primitive data type.

Examples of Java null reserved word

Example 1

Let's see a simple example to display the default value of the reference variable.

Output:

null

Example 2

Let's see an example to determine whether we can pass null to object reference variable.

Output:

null

Example 3

Let's see an example to display the default value of String.

Output:

null

Example 5

Let's see an example to provide null to the String variable.

Output:

value is null
Next TopicJava Keywords




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA