All Questions

1882
votes
33answers
842083 views

What is a NullReferenceException, and how do I fix it?

I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error?...
371
votes
11answers
271857 views

Why is my Spring @Autowired field null?

Note: This is intended to be a canonical answer for a common problem. I have a Spring @Service class (MileageFeeCalculator) that has an @Autowired field (rateService), but the field is null when I tr...
3330
votes
57answers
1014655 views

Avoiding != null statements

I use object != null a lot to avoid NullPointerExceptions. Is there a good alternative to this? For example: if (someobject != null) { someobject.doCalc(); } This avoids a NullPointerExcepti...
92
votes
4answers
135591 views

Select rows which are not present in other table

I've got two postgresql tables: table name column names ----------- ------------------------ login_log ip | etc. ip_location ip | location | hostname | etc. I want to get every IP ...
96
votes
6answers
45333 views

Method Overloading for null argument

I have added three methods with parameters: public static void doSomething(Object obj) { System.out.println("Object called"); } public static void doSomething(char[] obj) { System.out.prin...
203
votes
14answers
223363 views

What is null in Java?

What is null? Is null an instance of anything? What set does null belong to? How is it represented in the memory?
177
votes
11answers
221458 views

NOT IN clause and NULL values

This issue came up when I got different records counts for what I thought were identical queries one using a not in where constraint and the other a left join. The table in the not in constraint had o...
219
votes
11answers
196124 views

What is the difference between NULL, '\0' and 0

In C, there appear to be differences between various values of zero -- NULL, NUL and 0. I know that the ASCII character '0' evaluates to 48 or 0x30. The NULL pointer is usually defined as: #define ...
189
votes
10answers
63521 views

Why does Oracle 9i treat an empty string as NULL?

I know that it does consider ' ' as NULL, but that doesn't do much to tell me why this is the case. As I understand the SQL specifications, ' ' is not the same as NULL -- one is a valid datum, and ...
50
votes
2answers
20144 views

PostgreSQL sort by datetime asc, null first?

I need to sort a PostgreSQL table ascending by a date/time field, e.g. last_updated. But that field is allowed to be empty or null and I want records with null in last_updated come before non-null la...

Previous Next