Questions tagged [null]

Null means *nothing* or *unknown*, depending on context. Please use the "sql-null" tag for SQL specific questions.

"Null" has different meanings depending on context.

Set theory

Null is another name for the empty set, denoted by the symbol ∅. For this reason, some programming languages use null or nil for the empty list or empty tuple. Lisp uses nil to mean the empty list and the boolean value false.

Pointers and References

Null (or sometimes nil or None), in programming languages that support it, is the value of an uninitialized variable, a pointer that doesn't point to a meaningful memory address, or an object that fails to respond to any message.

Nullable references were invented by C.A.R. Hoare in 1965 as part of the Algol W language. Hoare later described his invention as a "billion-dollar mistake".

For more information, see Null pointer.

Agreeing with Hoare's sentiment, many languages don't have a special null value, choosing to use optional types instead.

Relational Databases

NULL as a special marker in SQL or a relational database stands in place of a value that is missing, or in a join means "no corresponding row." The operators IS NULL and IS NOT NULL are required for comparisons to a literal null: other comparisons between NULL and any value evaluate to "unknown."

For more information, see Null (SQL).

ASCII

Null or NUL is the name given to the character with ASCII code zero (0) - i.e. hex 00. In some languages, notably C, NUL is used to mark the end of a character string.

For more information, see Null character.

16208 questions
8
votes
3 answers

How can DBNull not equal DBNull

I have the following line of code if (DBNull.Value.Equals(o) || o != null) where o is object o in row.ItemArray I keep getting an error of --> Xml type "List of xdt:untypedAtomic" does not support a conversion from Clr type "DBNull" to Clr type…
Refracted Paladin
  • 12,096
  • 33
  • 123
  • 233
8
votes
6 answers

How to avoid NullPointerExceptions from boxed type arithmetic in Java?

Given the following: Integer var1 = null; Integer var2 = 4; Integer result = var1 + var2; // throws NullPointerException The requirement for my use case is that result should be null whenever either operand is null (and the same applies for other…
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
8
votes
6 answers

Using a for loop in Java, do I have to specify not null?

Well, I have a have a primitive array of objects, and because I can't remove them from the array, I instead change the object's position in the array to null. However, if I want to iterate over each object in the array, in the following way: for…
LaneWalker
  • 255
  • 6
  • 14
8
votes
2 answers

how to skip null values in odata response?

I have an odata web service that is returning some null values. I would like to skip these null values. I tried to use the Ne(Not equal) operator to filter the data with null…
Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117
8
votes
7 answers

Should References in Object-Oriented Programming Languages be Non-Nullable by Default?

Null pointers have been described as the "billion dollar mistake". Some languages have reference types which can't be assigned the null value. I wonder if in designing a new object-oriented language whether the default behavior should be for…
cdiggins
  • 17,602
  • 7
  • 105
  • 102
8
votes
2 answers

TypeError: must be string without null bytes, not str

I'm trying to run this code, to run the same command (with little changes) with every frame that I have: traj.reset() import os #os.chdir(outname) for i, frame in enumerate(traj): frame.superpose() comando = "python hollow.py -c constraint…
8
votes
2 answers

Spring MVC ModelAttribute Fields Are Null Instead of Form Input Values

I'm trying to make a form that will post a CardRequestResource: public class CardRequestResource extends ResourceSupport{ private Long cardRequestId; private String deliveryMethod; private String address; private boolean…
AForsberg
  • 1,074
  • 2
  • 13
  • 25
8
votes
5 answers

What is the PHP equivalent of Javascript's undefined?

My assumption followed by question based on the assumption: Javascript has null and undefined. You can set a variable to be null, implying it has no value, or you can set it to undefined, implying that it isn't known whether it has a value or not -…
Trindaz
  • 17,029
  • 21
  • 82
  • 111
8
votes
7 answers

C++ std::string and NULL const char*

I am working in C++ with two large pieces of code, one done in "C style" and one in "C++ style". The C-type code has functions that return const char* and the C++ code has in numerous places things like const char*…
pythonic metaphor
  • 10,296
  • 18
  • 68
  • 110
8
votes
3 answers

why the type of `nil` is not `id` but `void *`

In this code id (^block)(void) = ^(void) { return nil; }; I have this error Incompatible block pointer types initializing 'id (^__strong)(void)' with an expression of type 'void *(^)(void)' So I have to explicitly cast nil to id type id…
Bryan Chen
  • 45,816
  • 18
  • 112
  • 143
8
votes
3 answers

Attempting to access a null pointer

#include int main() { int* i = 0; int x = (*i); std::cout << x; } The above program will crash when I compile and run it using Visual Studio 2010 and I know it crashes because I set the pointer to 0. What I would like to…
Caesar
  • 9,483
  • 8
  • 40
  • 66
8
votes
4 answers

Modelling an equivalent of database NULL in RDF

I would like to know if there is a standard or generally accepted way of representing an equivalent of NULL used in databases for RDF data. More specifically, I'm interested in a way to distinguish the following cases for a value o of a property p…
Mifeet
  • 12,949
  • 5
  • 60
  • 108
8
votes
2 answers

Why this form is correct in C?

I have this piece of code in C: void f(void *x) { printf(">>> %p\n", x); } int main() { f NULL; return 0; } I think is for the definition of NULL, but I'd like an explanation to clarify my doubt.
Kyrol
  • 3,475
  • 7
  • 34
  • 46
8
votes
1 answer

Objective C iPhone when to set object references to nil

I have been developing with objective C and the Cocoa framework for quite some time now. However it is still not absolutely clear to me, when am I supposed to set object references to nil. I know it is recommended to do so right before releasing an…
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
8
votes
3 answers

ruby array checking for nil array

I have ruby array and it is nil but when I check using nil? and blank? it returns false @a = [""] @a.nil? => false @a.empty? => false How do I check for the nil condition that return true?
urjit on rails
  • 1,763
  • 4
  • 19
  • 36