Java language foundation - Identifier

Java language foundation - Identifier


What is the identifier?

  • In the Java source code among programmers who have the right to name their own words are identifiers.
  • Identifier may identify what elements?
    1. The class name
    2. Method name
    3. Interface name
    4. Constant name

Identifier naming rules? (grammar)

  • Only numbers, letters, underscores _ the dollar sign ($) composition, can not contain other symbols.
  • You can not start with a number
  • Strict distinction between the case
  • Keywords can not do identifier
  • In theory no length limit , it is best not too long

Naming identifiers? (Just standard, not part of the syntax, do not comply with specifications not being given)

  • Best to see to know the name meaning : that saw the name, I know this is what to do with.
  • Compliance hump naming :
    1. Class name, interface name : capitalize the first letter of each word capitalized later.
    2. Variable names, method names : lowercase first letter, after each initial capital letters.
    3. Constant name : All caps
Released three original articles · won praise 5 · Views 1629

Guess you like

Origin blog.csdn.net/lolly1023/article/details/104597910