Legacy Java Syntax

It’s a copy-paste error, I suppose.

From JLS 1 (which is really not that easy to find!), the section on local variable declarations states that such a declaration, in essence, is a type followed by an identifier. Note that there is no special reference made about *, but there is special reference made about [] (for arrays).

char is our type, so the only possibility that remains is that *cp is an identifier. The section on Identifiers states

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



A Java letter is a character for which the method Character.isJavaLetter (§20.5.17) returns true

And the JavaDoc for that method states:

A character is considered to be a Java letter if and only if it is a
letter (§20.5.15) or is the dollar sign character ‘$’ (\u0024) or the
underscore (“low line”) character ‘_’ (\u005F).

so foo, _foo and $foo were fine, but *foo was never valid.


If you want a more up-to-date Java style guide, Google’s style guide is the arguably the most commonly referenced.

Leave a Comment