I have these statements:
int \u65549 = 9;
System.out.println(\u65549);
This compiles perfectly. And outputs
9
But :
System.out.println(Character.isJavaIdentifierStart(\u65549));
outputs
false
This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the
isJavaIdentifierStart(int)
method.
Then I did this:
int x = \u65549;
System.out.println(Character.isJavaIdentifierStart(x));
But even this prints:
false
So, does this mean, that Java is confused over \u65549
being an identifier?
int \u65549 = 9;
System.out.println(Character.isJavaIdentifierStart(\u65549));
Here, \u65549
is the name of a variable, that also happens to contain the value 9
. It should (and does) do the same as if you wrote:
System.out.println(Character.isJavaIdentifierStart(9));
which prints false
, since you can't have a Java identifier starting with a whitespace character (\u0009
is the codepoint for HORIZONTAL TAB, '\t'
).
\u65549
is interpreted as the unicode character \u6554
, followed by the character 9
.
This is a valid syntax in a String
.
Other than that, \u65549
is not a valid unicode identifier.
A String only takes the valid part (4
characters in the hexadecimal range) when it encounters a unicode prefix (\u
), so it takes only the valid identifier part, and obtains a valid character .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With