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
95 views
asked May 12, 2014 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 May 12, 2014 by smith Geek (15,340 points)

Related questions

0 votes
1 answer 36 views
36 views asked Feb 18, 2014 by john Guru (27,140 points)
0 votes
2 answers 56 views
56 views asked Feb 18, 2014 by john Guru (27,140 points)
+1 vote
1 answer 46 views
0 votes
1 answer 13 views
0 votes
1 answer 98 views
98 views asked Dec 17, 2013 by rajesh Guru (39,140 points)
...