Gihan Madushanka wrote:Does not Java allow identifiers to be started with punctuation marks ?
Is it a must to create identifiers which adhere to those standards or is it a good programming practice ?
Jeff Verdegan wrote:
Any further naming conventions are not a must as far as Java is concerned, but might be a must as far as your isntructor or boss is concerned.
Maneesh Godbole wrote:
Jeff Verdegan wrote:
Any further naming conventions are not a must as far as Java is concerned, but might be a must as far as your isntructor or boss is concerned.
...and team mates. When I find code with names like s1,s2,s3,s3 it makes me see red
Gihan Madushanka wrote:Any idea about punctuation marks ?
Gihan Madushanka wrote:In java an identifier cannot start with a number. Therefore 3rd(in math e is a constant ) & 5th ones are obviously illegal identifiers.
Jesper de Jong wrote:
Gihan Madushanka wrote:In java an identifier cannot start with a number. Therefore 3rd(in math e is a constant ) & 5th ones are obviously illegal identifiers.
That's incorrect.
Just because in math, the letter e is being used to indicate a numerical constant, doesn't mean that e is a number in Java. So, that is not the reason why the 3rd is not allowed. If this were true, that would mean you couldn't have variables of which the name starts with the letter e. That would be madness!
Gihan Madushanka wrote:Is there any possible reason for 3rd one to be illegal?
Gihan Madushanka wrote:Is there any possible reason for 3rd one to be illegal?
Jesper de Jong wrote:
Gihan Madushanka wrote:Is there any possible reason for 3rd one to be illegal?
The 3rd one is illegal because it has # in it, which is not a valid character in an identifier.
Jeff Verdegan wrote:
Gihan Madushanka wrote:Is there any possible reason for 3rd one to be illegal?
You can answer that yourself by checking in the relevant section of the JLS.
Are you better than me? Then please show me my mistakes..
Supun Lakshan Dissanayake wrote:valid indentifiers should ONLY contains a to z, A to Z, 0 to 9, $(dollar sign), _(underscore) and
valid indentifier MUST begin with non digit character.
hope this was helpful
Maneesh Godbole wrote:When I find code with names like s1,s2,s3,s3 it makes me see red
Supun Lakshan Dissanayake wrote:valid indentifiers should ONLY contain a to z, A to Z, 0 to 9, $(dollar sign), _(underscore)
Ivan Jozsef Balazs wrote:
Supun Lakshan Dissanayake wrote:valid indentifiers should ONLY contain a to z, A to Z, 0 to 9, $(dollar sign), _(underscore)
Nope. Valid idenitifers can contain JavaLetters,
JavaLetter:
any Unicode character that is a Java letter
Are you better than me? Then please show me my mistakes..
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|