The null Keyword and Garbage Collection
Previous | Home | Next |
Null Keyword;-
The null keyword in java programming language is a reserved word that is used to represent no value.
Garbage collection:-
In Java when program executes the JVM creates the object of the Java classes which is to be executed. In this process these objects are stored into memory. When these objects are not need the JVM process removes these objects and then reclaims the memory. This process of finding the unused Java objects and then freeing objects which is no longer is in use is called the Garbage Collection.
Null Keyword
The null keyword in java programming language is a reserved word that is used to represent no value.
Primitive data types such as byte, short, int, long, char, float, double, Boolean cannot have a null type.
Assigning a null value to a non-primitive type variable releases the object to which the variable previously referred.
Garbage collection in java
In Java when program executes the JVM creates the object of the Java classes which is to be executed. In this process these objects are stored into memory. When these objects are not need the JVM process removes these objects and then reclaims the memory. This process of finding the unused Java objects and then freeing objects which is no longer is in use is called the Garbage Collection.
syntax for null keywordInteger x;Garbage collection
x = null;
String str;
if (str != null)
{
statements
}
Null key wordInteger x;
x = null;
String str;
if (str != null)
{
statements
}
Previous | Home | Next |