为什么十六进制在 Java 中不区分大小写?

Why hexadecimal is not case sensitive in Java?

如果Java是一种区分大小写的语言那么为什么十六进制值不是 区分大小写?

int x = 0x21af3;
int y = 0X21AF3;

System.out.println(x==y);

它 returns 是的。谁能解释一下为什么十六进制不区分大小写?

因为 Java 语言规范说它不区分大小写。

3.10.1. Integer Literals下:

A hexadecimal numeral consists of the leading ASCII characters 0x or 0X followed by one or more ASCII hexadecimal digits interspersed with underscores, and can represent a positive, zero, or negative integer.

Hexadecimal digits with values 10 through 15 are represented by the ASCII letters a through f or A through F, respectively; each letter used as a hexadecimal digit may be uppercase or lowercase.