C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

how can we use The null Keyword?

0 votes
100 views
asked by rock Expert (14,990 points)

1 Answer

0 votes
You can test if a reference variable is null by using the == operator. For instance.

public class MainClass {

  public static void main(String[] args) {
    String book = null;
   
    if (book == null) {
        book = new String();
    }
  }
}
answered by smith Geek (15,340 points)

Related questions

0 votes
1 answer 37 views
37 views asked by john Guru (27,140 points)
0 votes
2 answers 57 views
+1 vote
1 answer 50 views
0 votes
1 answer 13 views
0 votes
1 answer 115 views
115 views asked by rajesh Guru (39,140 points)
...