gpt4 book ai didi

java - Java 类名中的有效字符

转载 作者:太空宇宙 更新时间:2023-11-04 13:48:26 25 4
gpt4 key购买 nike

Java 类名中哪些字符有效?还有哪些其他规则管理 Java 类名称(例如,Java 类名称不能以数字开头)?

最佳答案

您几乎可以使用任何字符,包括大多数 Unicode 字符!确切的定义在 the Java Language Specification under section 3.8: Identifiers .

An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter. ...

Letters and digits may be drawn from the entire Unicode character set, ... This allows programmers to use identifiers in their programs that are written in their native languages.

An identifier cannot have the same spelling (Unicode character sequence) as a keyword (§3.9), boolean literal (§3.10.3), or the null literal (§3.10.7), or a compile-time error occurs.

但是,请参阅this question是否应该这样做。

关于java - Java 类名中的有效字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30578915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com