Why is “null” present in C# and Java?

前端 未结 25 1970
别那么骄傲
别那么骄傲 2020-11-29 22:09

We noticed that lots of bugs in our software developed in C# (or Java) cause a NullReferenceException.

Is there a reason why \"null\" has even been included in the l

25条回答
  •  臣服心动
    2020-11-29 22:43

    Like many things in object-oriented programming, it all goes back to ALGOL. Tony Hoare just called it his "billion-dollar mistake." If anything, that's an understatement.

    Here is a really interesting thesis on how to make nullability not the default in Java. The parallels to C# are obvious.

提交回复
热议问题