什么是“连接字符"?在 Java 标识符中? [英] What are "connecting characters" in Java identifiers?
问题描述
我正在为 SCJP 阅读,我对此行有疑问:
I am reading for SCJP and I have a question regarding this line:
标识符必须以字母、货币字符 ($) 或连接字符,例如下划线 (_).标识符不能以数字开头!
Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ ). Identifiers cannot start with a number!
它指出有效的标识符名称可以以连接字符例如下划线开头.我认为下划线是唯一有效的选项?还有哪些连接字符?
It states that a valid identifier name can start with a connecting character such as underscore. I thought underscores were the only valid option? What other connecting characters are there?
推荐答案
这是连接字符的列表.这些是用于连接单词的字符.
Here is a list of connecting characters. These are characters used to connect words.
http://www.fileformat.info/info/unicode/类别/PC/list.htm
U+005F _ LOW LINE
U+203F ‿ UNDERTIE
U+2040 ⁀ CHARACTER TIE
U+2054 ⁔ INVERTED UNDERTIE
U+FE33 ︳ PRESENTATION FORM FOR VERTICAL LOW LINE
U+FE34 ︴ PRESENTATION FORM FOR VERTICAL WAVY LOW LINE
U+FE4D ﹍ DASHED LOW LINE
U+FE4E ﹎ CENTRELINE LOW LINE
U+FE4F ﹏ WAVY LOW LINE
U+FF3F _ FULLWIDTH LOW LINE
这在 Java 7 上编译.
This compiles on Java 7.
int _, ‿, ⁀, ⁔, ︳, ︴, ﹍, ﹎, ﹏, _;
<小时>
一个例子.在这种情况下,tp
是列名和给定行的值.
An example. In this case tp
is the name of a column and the value for a given row.
Column<Double> ︴tp︴ = table.getColumn("tp", double.class);
double tp = row.getDouble(︴tp︴);
<小时>
以下
for (int i = Character.MIN_CODE_POINT; i <= Character.MAX_CODE_POINT; i++)
if (Character.isJavaIdentifierStart(i) && !Character.isAlphabetic(i))
System.out.print((char) i + " ");
}
印刷品
$ _¢£¤¥؋৲৳৻૱௹฿៛‿⁀⁔₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹꠸﷼_︴﹎ ﹏ ﹩ $ _ ¢ £ ¥ ₩
$ _ ¢ £ ¤ ¥ ؋ ৲ ৳ ৻ ૱ ௹ ฿ ៛ ‿ ⁀ ⁔ ₠ ₡ ₢ ₣ ₤ ₥ ₦ ₧ ₨ ₩ ₪ ₫ € ₭ ₮ ₯ ₰ ₱ ₲ ₳ ₴ ₵ ₶ ₷ ₸ ₹ ꠸ ﷼ ︳ ︴ ﹍ ﹎ ﹏ ﹩ $ _ ¢ £ ¥ ₩
这篇关于什么是“连接字符"?在 Java 标识符中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!