Reading the Java Code Conventions document from 1997, I saw this in an example on P16 about variable naming conventions:
int i; char *cp; float myWidth;
The second declaration is of interest - to me it looks a lot like how you might declare a pointer in C. It gives a syntax error when compiling under Java 8.
Just out of curiosity: was this ever valid syntax? If so, what did it mean?
What Is Legacy Code? Legacy code is source code inherited from someone else or inherited from an older version of the software. It can also be any code that you don't understand and that's difficult to change.
In computing, a legacy system is an old method, technology, computer system, or application program, "of, relating to, or being a previous or outdated computer system", yet still in use. Often referencing a system as "legacy" means that it paved the way for the standards that would follow it.
The Enumeration interface is the only legacy interface. It defines methods, which help us to enumerate the elements in a collection of objects. This interface has been suspended by Iterator.
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes? Explanation: Dictionary, Map & Hashtable all implement Map interface hence all of them uses keys to store value in the object. 4.
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.
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