Search code examples
javanamingabbreviation

How to abbreviate "number of <items>" in source code?


I'm new to learning Java and I'm bad at English but I try my best to write good, understandable source code.

I want to make variables to save the "number of cars" or "number of items". How do I abbreviate "number of ..." without using symbols like # that don't work in a source code?

Thanks


Solution

  • You have several choices to do that

    1. numberOfItems (verbose, but clear in meaning)
    2. numItems (it's ok)
    3. itemCount (probably, the best — what I'd have used)
    4. items (shortest, but can't know if it is an integer or a list of items)