V2EX  ›  英汉词典
Enqueued related words: Illegalstateexception

IllegalArgumentException

Definition / 释义

IllegalArgumentException:Java 中常见的运行时异常(RuntimeException 的子类),表示方法接收到不合法或不合适的参数(例如参数为负数、超出范围、格式不符合要求、与业务约束冲突等)。通常用于提示“调用方传参错误”。

Pronunciation / 发音

/ɪˌliːɡəl ˈɑːrɡjʊmənt ɪkˈsɛpʃən/

Examples / 例句

Pass a negative size and the method will throw an IllegalArgumentException.
传入负数的大小参数时,该方法会抛出 IllegalArgumentException。

To protect invariants, the constructor validates inputs and throws IllegalArgumentException when the string is null or its length exceeds the limit.
为保证不变量,构造函数会校验输入;当字符串为 null 或长度超过限制时将抛出 IllegalArgumentException。

Etymology / 词源

该词由三部分构成:illegal(非法的/不符合规则的)+ argument(参数)+ exception(异常)。在 Java 命名习惯中以 CamelCase 形式出现,用来直观表达“由于参数不合法而产生的异常”。它是 Java 标准库中用于参数校验的经典异常类型之一。

Related Words / 相关词

Literary & Notable Uses / 文学与著名用例

  • Effective Java(Joshua Bloch)——讨论参数校验与在何时抛出 IllegalArgumentException 等异常类型。
  • Java Concurrency in Practice(Brian Goetz 等)——在示例与 API 约束说明中常用该异常表达“调用方参数不满足前置条件”。
  • Spring in Action(Craig Walls)及相关 Spring 文档/源码示例——在参数检查与框架 API 使用中频繁出现该异常。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1126 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 18:17 · PVG 02:17 · LAX 11:17 · JFK 14:17
♥ Do have faith in what you're doing.