search
Login

Categories


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

3.8k questions

4k answers

117 comments

10.7k users

0 votes
111 views
asked Expert 15k points 15 23 30

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 Geek 15.3k points 16 41 63

Related questions

0 votes
1 answer 39 views
39 views
asked john Guru 27.1k points 31 50 97
0 votes
2 answers 61 views
61 views
asked john Guru 27.1k points 31 50 97
1 vote
1 answer 54 views
0 votes
1 answer 15 views
15 views
asked sara Guru 24.6k points 29 52 81
0 votes
1 answer 168 views
168 views
asked rajesh Guru 39.1k points 10 21 33
...