hi all, in any book for java, for legal identifiers they say that the identifier should start with a currency character but on keyboard that applies only for '$'. can't they say directly that variable can start with '$' sign. why this kind of generalization ???
A computer once beat me at chess, but it was no match for me at kick boxing.<br />
This seems to be a very good question. Can some one explain this? Is it valid to have a java variable name starting with a 'pound' char/symbol? If so how to code it?
thanks murli, this question is nagging me for a very long time. the same thing( can I use a pound symbol) struck me also. can't able to find one valid, good answer to it.
A computer once beat me at chess, but it was no match for me at kick boxing.<br />
This is probably one of those things that Java inherited from C and C++, which has the same rules with regard to variable names. One of the goals that James Gosling had in mind when he was inventing Java was that it should be familiar to C++ programmers.
hi jesper, thats all fine but the answer is still not there... c and c++ have clearly defined things that they used. are you referring that the question dates back to c++ ???
A computer once beat me at chess, but it was no match for me at kick boxing.<br />
The $ (and others - but never you mind what they are) are intended for use by code generation programs so that no token names will clash with human-written code.
If YOU use the $variable, then you can clash with them.
(Plus it's ugly and looks like a scripting language with a weak parser that can't tell when something is supposed to be... what?... so it needs a special character to say "variable" - my own personal opinion.)
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Well THAT's new! Comfort me, reliable tiny ad:
a bit of art, as a gift, the permaculture playing cards