I consider the item described in: Effective Java by Joshua Bloch authoritative in this matter:
Adhere to generally accepted naming conventions
Class and interface names should consist of one or more words, with the first
letter of each word capitalized [..] Abbreviations
are to be avoided, except for acronyms and certain common abbreviations like max
and min. [...] a strong
argument can be made in favor of capitalizing only the first letter. [...] you can still tell where one word starts and the next word ends. Which class name would you rather see, HTTPURL or HttpUrl?
For acronyms, uppercase only the first letter. Definitely. Ignore the fact that some JDK methods don't.
But "id" is one of the strangest words in the language -- an abbreviation for which no one even really knows exactly what it's short for. Some have suggested "identifying document", but this is likely just made up after the fact. 'identifiying... something' is about the best we have. Anyway, if you were to use userID, it suggests that a plain id would be iD, and you sure as heck don't want to do that, so the winner is:
userId
(as others have said).
So it ends up being treated like an acronym anyway.
It mainly depends on your naming convention together with your application (if there are any). For instance, userId is a preferred one with Java convention
This is quite a handy resource for Java naming conventions http://geosoft.no/development/javastyle.html
I consider the item described in: Effective Java by Joshua Bloch authoritative in this matter:
Adhere to generally accepted naming conventions
So, It should be
userId
It's like this:
userID
, it suggests that a plain id would beiD
, and you sure as heck don't want to do that, so the winner is:userId
(as others have said).
So it ends up being treated like an acronym anyway.
This is a tough decision, even Sun isn't so sure what to do. Look at classes in JRE,
Personally, I prefer to use camel-case always to be consistent.
It mainly depends on your naming convention together with your application (if there are any). For instance, userId is a preferred one with Java convention
The first one is preferred according to Java naming convention (1) (2).