Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'd say 2)
Underscore is legal and I think period is not. And the $ character is used internally for anonymous classes and the like so I'd bet that is legal too. -
@cafecortado Well done, well done... Yes, 2) is correct. And indeed, period is not legal, while underscore and $ are.
-
Came here to make the same guess as @cafecortado
It makes sense that . is not legal, otherwise it would conflict with the member access syntax. -
I thought it was 2 because you can't start with a number, and the $ makes it not start with a number. I forgot about anonymous inner-classes as mentioned by others. This just creates a variable named "$50_00," right? Nothing special about it?
-
JS (browser) equivalent:
window["$50.00"] = "JavaScript"
window["$50_00"] = "likes"
window["50"] = "it"
window["else"] = "rough"
1-4 are valid and you can even reference #2 without PO(JS)O notation.
Related Rants

Coworker's whiteboard today
Fun Java test:
Without looking up anything, answer the following question:
Which of the following variable identifiers is legal in Java and why?
1) float $50.00;
2) float $50_00;
3) float 50;
4) float else;
question
java
quiz
identifiers