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
7
votes
4 answers

"? extends ParentClass" makes Read only?

In the following code Java, I have created a list nums. I can assign the another list during the declaration. But new items cannot be added except the null. So, does it mean the nums is readonly? Why? Is it possible to add new items in that…
Pradip Kharbuja
  • 3,442
  • 6
  • 29
  • 50
7
votes
5 answers

Is it legal/well-defined C++ to call a non-static method that doesn't access members through a null pointer?

I came across the following code recently: class Foo { public: void bar(); // .. other stuff }; void Foo::bar() { if(!this) { // .. do some stuff without accessing any data members return; } // .. do normal…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
7
votes
1 answer

Android data.getData() returns null from CameraActivity for some phones

I have a fatal error occurring in my onActivityResult coming back from a camera activity. What has me scratching my head is that the error is only happening on a handful of phones (based on the number of affected users) while there seems to be…
John Riggs
  • 484
  • 1
  • 4
  • 17
7
votes
1 answer

MySQL returns last inserted when querying IS NULL

Whenever I do a SELECT statement with WHERE id is NULL directly after an INSERT, I get the last inserted row. I am using MySQL 5.1.73. It happens directly in the MySQL shell; here is my console: mysql> CREATE TABLE testing ( -> id int(11)…
mtricht
  • 427
  • 4
  • 16
7
votes
6 answers

Difference between uninitialized and null pointer

Is there any difference between null pointer and uninitialized pointer? This question was asked in one of the interviews. Could you please explain the difference that they have?
Namandeep_Kaur
  • 368
  • 1
  • 3
  • 11
7
votes
5 answers

Count the number of attributes that are NULL for a row

I want to add a new column to a table to record the number of attributes whose value are null for each tuple (row). How can I use SQL to get the number? for example, if a tuple is like this: Name | Age | Sex -----+-----+----- Blice| 100 | null I…
Kingston Chan
  • 923
  • 2
  • 8
  • 25
7
votes
1 answer

C++ allocator::deallocate(NULL,1) allowed?

Both free(NULL) and ::operator delete(NULL) are allowed. Does the allocator concept (e.g. std::allocator also allow deallocate(NULL,1), or is it required to put your own guard around it?
Jonathan Graehl
  • 9,182
  • 36
  • 40
7
votes
1 answer

Sort when values are None or empty strings python

I have a list with dictionaries in which I sort them on different values. I'm doing it with these lines of code: def orderBy(self, col, dir, objlist): if dir == 'asc': sorted_objects = sorted(objlist, key=lambda k: k[col]) else: …
Tryggast
  • 197
  • 2
  • 12
7
votes
5 answers

Replace the empty or NULL value with specific value in HIVE query result

I'm trying to show a default value, "Others", when the query does not return any result for one of the selected columns. I'll show you the example. This query returns an empty value for os(agent) SO (in the first row): select country, os(agent) SO,…
7
votes
4 answers

How to avoid returning NULL value in a function (JAVA)?

Supposed I have a List and have a function that return the reference of that object if available. SomeObject GetSomeObject(List, int x){ /* Search for object in list that has a properties with value x */ if…
jamesalone
  • 301
  • 1
  • 6
  • 19
7
votes
3 answers

Option.map (null) returns Some (null)

I want to this code snippet return me None instead of Some(null): Option(x).map(x.getNullValue) // returns Some(null) I heard Scalaz library has features to handle such case. So how I can achieve my goal using both: scalaz and standard Scala…
WelcomeTo
  • 19,843
  • 53
  • 170
  • 286
7
votes
3 answers

nullable type and a ReSharper warning

I have the following code: private static LogLevel? _logLevel = null; public static LogLevel LogLevel { get { if (!_logLevel.HasValue) { _logLevel = readLogLevelFromFile(); } return…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
7
votes
3 answers

java/beans validation - collection/map does not contain nulls

There is the @NotNull annotation which validates that a certain object is not null. There is the @NotEmpty annotation which validates that a certain collection/map/string/... is not empty. Is there also an annotation which valides that a certain…
user4460845
7
votes
0 answers

wave.getState() returns null

When trying to call wave.getState() in my Google Wave gadget, I get back null (no state object). How can I initialize the Wave state object? I am working in the Wave Sandbox. My ModulePrefs contains the following:
RMorrisey
  • 7,637
  • 9
  • 53
  • 71
7
votes
2 answers

Why does MySQL ignore null values when looking for not equal?

I am noticing something weird in MySQL and I would like to see why it behaves this way and of there a way to change it? Scenario I have accounts InnoDB table with the following columns id, name, type where the type is a null-able. Now, lets say I…
Jaylen
  • 39,043
  • 40
  • 128
  • 221
1 2 3
99
100