Urgent.News

What's breaking now, across thousands of outlets.

More in Tech

When SQL Has Nothing to Say: Understanding NULLs

NULL in SQL carry different meanings; missing value unknown value no value inapplicable data customer_id customer_name contact 101 Alice 0712345678 102 Brian NULL 103 Carol 0798765432 You shouldn't…

  • NULL in SQL signifies missing, unknown or not applicable values
  • SQL uses three-valued logic with TRUE, FALSE and UNKNOWN
  • IS NULL and IS NOT NULL functions retrieve rows with or without NULL values

The hashCode()-to-Array-Index Bug Almost Everyone Writes Once

"hash % capacity" looks trivial until you trace it by hand. Two separate bugs hide in that one line — and the fix for one of them has its own hole.

  • Modulo operator returns signed 32-bit integer, can be negative
  • Math.abs() fails for Integer.MINVALUE, no positive counterpart
  • Math.floorMod() ensures non-negative result for all integers

More from Sunday 6 September →