> identifiers in java ~ Online tutorial

identifiers in java

  • Identifiers Identifiers are names for things that the programmer creates in the program – variables, constants, methods and classes for example.
  • We’ve already used identifiers such as HelloWorldConsole and label1.
Rules for creating identifiers:

  • Identifiers must consist of letters, digits and _ (underscores) only.

  • Identifiers must begin with a letter.

  • Technically this is not true. _ can be used to start an identifier also, but this is usually done only for advanced programming that we won't be doing, so we will consider this statement to be completely true.

  • The number of characters in an identifier is theoretically unlimited but should be a reasonable limit. Something around 20 characters or less is usually about right. Identifiers can't be any of the Java keywords such as public.

  • The program won't compile. Identifiers shouldn't be any of the Java standard identifiers such as Scanner, which causes programmer confusion though Java won't get confused.

  • Java will use your meaning of the identifier, not the standard meaning.
    Identifiers should, but don't have to, be meaningful.

  • averageGPA conveys much more meaning and is easier to read than ag.

  • Here are example of good identifiers.
    total                            body12                  
    sumOfScores              countOfClicks        
    xPositionOnScreen      maxScore  

    Please Give Us Your 1 Minute In Sharing This Post!
    Please Give Us Your 1 Minute In Sharing This Post!
    SHARE IT →
    Powered By: BloggerYard.Com