This was intended as a meme but is actually a good representation of what "Null" is. In C#, when you declare string s = "My shit"; it means that "s" is a reference to a memory location that holds the data "My shit". string s = null; means that the reference "s" exists but it's not pointing to any object, as in it holds nothing. Answer from abd53 on reddit.com
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Null
Null - Glossary - MDN Web Docs
In computer science, a null value represents a reference that points, generally intentionally, to a nonexistent or invalid object or address. The meaning of a null reference varies among language implementations.
Discussions

language agnostic - What is the purpose of null? - Stack Overflow
Just like a negative length, distance or age is an edge case. You need to make sure that can't happen (by disallowing it in a constructor for example) or program defensively against it. 2020-12-09T20:36:06.997Z+00:00 ... Null is not a mistake. Null means "I don't know yet" More on stackoverflow.com
🌐 stackoverflow.com
java - What does is mean by null pointing to nothing and why use null at all? - Stack Overflow
From the languages you listed, it somewhat close to nothing in VB and not so close to NULL in SQL. ... If you understand C, this problem would be trivial. ... @Skippy: What I meant is that if you want to be a serious programmer, you should learn C. More on stackoverflow.com
🌐 stackoverflow.com
What is Null?
This was intended as a meme but is actually a good representation of what "Null" is. In C#, when you declare string s = "My shit"; it means that "s" is a reference to a memory location that holds the data "My shit". string s = null; means that the reference "s" exists but it's not pointing to any object, as in it holds nothing. More on reddit.com
🌐 r/learnprogramming
60
34
July 5, 2024
Where do NULL values come from in datasets and how to handle them?
It is fine to have null values in data sets. If something can be NULL you are saying, it’s okay to not have it. You just need to make sure that when operating on something that could be null you are checking before operating on it. If(possiblyNullValue) {console.log(“it’s not null”)} More on reddit.com
🌐 r/learnprogramming
6
2
June 8, 2024
🌐
freeCodeCamp
freecodecamp.org › news › a-quick-and-thorough-guide-to-null-what-it-is-and-how-you-should-use-it-d170cea62840
A quick and thorough guide to ‘null’: what it is, and how you should use it
June 12, 2018 - If a person's dateOfFirstMarriage field points to null then it simply means that this person has never been married. Note: Unfortunately most popular programming languages don’t distinguish between nullable and non-nullable types. There is no way to reliably state that null can never be assigned to a given object reference. In some languages it is possible to use annotations, such as the non-standard annotations @Nullable and @NonNullable in Java.
Top answer
1 of 16
49

Null: The Billion Dollar Mistake. Tony Hoare:

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. In recent years, a number of program analysers like PREfix and PREfast in Microsoft have been used to check references, and give warnings if there is a risk they may be non-null. More recent programming languages like Spec# have introduced declarations for non-null references. This is the solution, which I rejected in 1965.

2 of 16
32

null is a sentinel value that is not an integer, not a string, not a boolean - not anything really, except something to hold and be a "not there" value. Don't treat it as or expect it to be a 0, or an empty string or an empty list. Those are all valid values and can be geniunely valid values in many circumstances - the idea of a null instead means there is no value there.

Perhaps it's a little bit like a function throwing an exception instead of returning a value. Except instead of manufacturing and returning an ordinary value with a special meaning, it returns a special value that already has a special meaning. If a language expects you to work with null, then you can't really ignore it.

🌐
Khoury College of Computer Sciences
khoury.northeastern.edu › home › kenb › MeaningOfNull.html
The Meaning of Null in Databases and Programming Languages
The main distinction between the relational null and the programming language null is the following: The relational null represents the absence of a value in a field of a record; whereas the programming language null represents one of the possible values of a variable.
🌐
Medium
medium.com › @sumeet2703 › understanding-the-difference-between-zero-and-null-in-programming-db60b4e12934
Understanding the Difference Between Zero and Null in Programming | by Sumeet K | Medium
September 4, 2024 - Different programming languages handle null (or its equivalents) in various ways, but the concept remains consistent: No Value: Null indicates that a variable doesn't point to any object or value in memory.
🌐
Quora
quora.com › What-does-NULL-mean-in-programming-languages
What does NULL mean in programming languages? - Quora
Answer (1 of 6): null is the pointer or reference to address zero. Why would this be needed or used? Let’s say you are searching for a library book that you want to read. Unlike Amazon, your library doesn’t have every book.
Find elsewhere
🌐
TechCareer
techcareer.net › en › dictionary › null
What is Null? What does it do?
Null, in many programming languages, means "empty" or "nothing." It is used to indicate that a variable has no value. Null shows that an object or reference does not contain any data or does not point to an object.
🌐
TechTerms
techterms.com › definition › null
Null Definition - What does null mean to a computer?
September 26, 2022 - It does not mean a value of 0, since 0 is itself a value, nor does it mean a blank space " ". It also does not refer to an undefined variable, which has not been created at all. In the context of programming languages, a variable that has no value assigned is considered null.
🌐
Medium
robertdelwood.medium.com › thinking-like-a-programmer-understanding-null-959a5da1d625
Thinking Like a Programmer: Understanding Null | by Robert Delwood | Medium
September 21, 2025 - A null or nothing means there is no value for developers to read or use. If unchecked, that value results in an error. That’s why the null check needs to be there. ... Programmer/writer/programmer-writer.
🌐
ThoughtCo
thoughtco.com › definition-of-null-958118
What Does Null Mean in C, C++ and C#?
April 27, 2019 - Null is a constant built into C, C++, and C#. It has a value of zero. Null can also be the value of a pointer that points nowhere.
🌐
DevX
devx.com › home › null
Null - Glossary
January 17, 2024 - Null is an essential concept in the realm of technology that plays a critical role in managing and handling data. Its purpose is to represent an empty or non-existent value, particularly in programming and databases.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › csharp › language-reference › keywords › null
null keyword - C# reference | Microsoft Learn
Access to this page requires authorization. You can try changing directories. ... The null keyword is a literal that represents a null reference, one that doesn't refer to any object.
🌐
Coderanch
coderanch.com › t › 688734 › java › null
what does null mean? (Beginning Java forum at Coderanch)
December 24, 2017 - I can't always remember when to ... objects that just have the same value as one another. ... From my understanding of null, it means the variable has no value....
🌐
Wikipedia
en.wikipedia.org › wiki › Null
Null - Wikipedia
2 weeks ago - Null (SQL) (or NULL), a special marker and keyword in SQL indicating that a data value does not exist, is not known, or is missing.
🌐
Upwork
upwork.com › resources › articles › null in java: understanding the basics
Null in Java: Understanding the Basics - Upwork
August 5, 2024 - In Java, null is a literal used to denote the absence of an object. It is strictly typed, meaning it can only be assigned to reference types. Null checks are a common practice to prevent NullPointerExceptions, which can crash the program if ...
🌐
YouTube
youtube.com › watch
Definition: What is a Null Value? - YouTube
What is a Null Value - well it is where no value has been set for a variable. We look at examples of these in programming languages in this short video to de...
Published   August 19, 2020
🌐
Programmer's Wiki
code.fandom.com › wiki › Null
Null | Programmer's Wiki | Fandom
null (often NULL, or nil) is a constant used in many programming languages to indicate that the expected value is unknown. It is different from 0, the empty string, and false because these are known to be empty.
🌐
Wikipedia
en.wikipedia.org › wiki › Null_function
Null function - Wikipedia
March 26, 2026 - In computer science, a null function (or null operator) is a subroutine that leaves the program state unchanged. When it is part of the instruction set of a processor, it is called a NOP or NOOP (No OPeration). ... {\displaystyle s} unchanged. That is, a null function is an identity function ...
Top answer
1 of 9
6
String str = null;

means a String reference, named str, not pointing to anything

String str = "";

means a String reference, named str, pointing to an actual String instance. And for that String instance, it is a zero-length String, but it is still an actual object.


Just a little update with some diagram which hopefully can help you visualize that:

assume I have

String nullStr = null;
String emptyStr = "";
String myStr = "ab";

What it conceptually is something look like:

  // String nullStr = null;

  nullStr ----------> X    pointing to nothing



  // String emptyStr = "";
                      +------------------+
  emptyStr ---------> |       String     |
                      +------------------+
                      | length = 0       |
                      | content = []     |
                      +------------------+


  // String myStr = "ab";
                      +------------------+
  myStr ------------> |       String     |
                      +------------------+
                      | length = 2       |
                      | content = [ab]   |
                      +------------------+

(of course the internal structure of the String object is not the real thing in Java, it is just for giving you an idea)


More edit for the rationale behind NULL:

In fact in some language they do not provide concept of NULL. Anyway, in Java (or similar language), Null means semantically different from "empty" object. Use String as an example, I may have a People class with a String preferedTitle attribute. A Null preferedTitle means there is NO preferred title for that people (so that we need to derive and show the title for it, maybe), while a preferedTitle being an empty string means there IS a preferred title, and that's showing nothing.

Btw, although a bit off topic: concept of Null is seen as problematic for some people (because all those extra handling it need etc). Hence some languages (e.g. Haskell) are using some other ways to handle the situation where we used to use Null.

2 of 9
4

String str is a reference to an object. That is, it's not an actual object, but a variable which can contain the address of an object. When you assign a value to str you are changing the address stored within and changing which object it addresses.

null is reference value which points to no object. It's about as close to nothing as you can get. If you assign null to a String reference (String str = null;), you cannot then invoke any method of String using that reference -- all attempts will result in NullPointerException.

"" is a character String which contains no characters -- zero length. It is still an object, though, and if you assign its address to your String reference variable (String str = "";) you can then take its length, compare it to another String, extract its hashCode, etc.