A connecting character is used to connect two characters.
In Java, a connecting character is the one for which Character.getType(int codePoint)/Character.getType(char ch) returns a value equal to Character.CONNECTOR_PUNCTUATION.
Note that in Java, the character information is based on Unicode standard which identifies connecting characters by assigning them the general category Pc, which is an alias for Connector_Punctuation.
The following code snippet,
for (int i = Character.MIN_CODE_POINT; i <= Character.MAX_CODE_POINT; i++) {
if (Character.getType(i) == Character.CONNECTOR_PUNCTUATION
&& Character.isJavaIdentifierStart(i)) {
System.out.println("character: " + String.valueOf(Character.toChars(i))
+ ", codepoint: " + i + ", hexcode: " + Integer.toHexString(i));
}
}
prints the connecting characters that can be used to start an identifer on jdk1.6.0_45
character: _, codepoint: 95, hexcode: 5f
character: ‿, codepoint: 8255, hexcode: 203f
character: ⁀, codepoint: 8256, hexcode: 2040
character: ⁔, codepoint: 8276, hexcode: 2054
character: ・, codepoint: 12539, hexcode: 30fb
character: ︳, codepoint: 65075, hexcode: fe33
character: ︴, codepoint: 65076, hexcode: fe34
character: ﹍, codepoint: 65101, hexcode: fe4d
character: ﹎, codepoint: 65102, hexcode: fe4e
character: ﹏, codepoint: 65103, hexcode: fe4f
character: _, codepoint: 65343, hexcode: ff3f
character: ・, codepoint: 65381, hexcode: ff65
The following compiles on jdk1.6.0_45,
int _, ‿, ⁀, ⁔, ・, ︳, ︴, ﹍, ﹎, ﹏, _, ・ = 0;
Apparently, the above declaration fails to compile on jdk1.7.0_80 & jdk1.8.0_51 for the following two connecting characters (backward compatibility...oops!!!),
character: ・, codepoint: 12539, hexcode: 30fb
character: ・, codepoint: 65381, hexcode: ff65
Anyway, details aside, the exam focuses only on the Basic Latin character set.
Also, for legal identifers in Java, the spec is provided here. Use the Character class APIs to get more details.
_
is a "deprecated" identifier. Specifically, the compiler emits the following warning: (use of '_' as an identifier might not be supported in releases after Java SE 8). – Skepticism_
for use in future language features. Identifiers that start with an underscore are still okay, but a single underscore is an error if used as a lambda parameter name, and a warning everywhere else. – Hastings. ; [ / < > :
goes: #26791704 docs.oracle.com/javase/specs/jvms/se7/html/… Everything else is a Java-only restriction. – Griner