V2EX  ›  英汉词典
Enqueued related words: Guard Clause, NullPointerException

Null Check

释义 Definition

(编程)空值检查 / 空指针检查:在使用变量、对象或引用之前,先判断它是否为 null(空引用),以避免运行时错误(如空指针异常)。在不同语言中也常指对“缺失值”的检查。

发音 Pronunciation (IPA)

/nʌl tʃek/

例句 Examples

Please do a null check before calling the method.
在调用这个方法之前,请先做空值检查。

The bug happened because the code accessed a field without a proper null check, causing the program to crash.
这个问题发生是因为代码在没有进行正确空值检查的情况下访问了字段,导致程序崩溃。

词源 Etymology

null 来自拉丁语 nullus(意为“没有、无”),在现代编程语境中表示“空引用/无值”。check 源自古法语 eschequier(与“检查、核对”相关)。两者组合成 null check,直观表示“检查是否为空”。

相关词 Related Words

文学与作品 Notable Works

  • Clean Code(Robert C. Martin):讨论通过清晰结构与防御性写法减少不必要的空值检查、降低错误率。
  • Effective Java(Joshua Bloch):涉及对空值的处理策略(如参数校验、避免返回 null、使用替代方案)。
  • The Pragmatic Programmer(Andrew Hunt & David Thomas):在“健壮性/防御性编程”相关章节中提及对异常与无效值(包含 null)的处理。
  • Code Complete(Steve McConnell):在错误处理与输入检查相关内容中谈到空值/无效引用检查的重要性。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1150 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 16:19 · PVG 00:19 · LAX 08:19 · JFK 11:19
♥ Do have faith in what you're doing.