您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes
Introduction
Content
Apply
Reflect
Extend
previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Content Index
Content Page # 19

Identifier naming conventions

Although not actually a layout convention, another convention that can be very useful for improving program clarity is in the choice of identifiers (names). Classes, methods and variables have identifiers, and the conventional rules for their spelling (which we adopt for this module) are as follows:

  • classes start with the first letter capitalised, and have the first letter of each subsequent word capitalised too, for example:

  •  
      String
      BankAccount
      TaxReturn
  • constructor methods start with a capital letter, and follow the same convention as for classes ?since a constructor method has to have the same name as the class. Examples could be:

  •  
      String
      BankAccount
      RandomBall
  • variables and all other methods start with a lower case first letter, and have the first letter of each subsequent word capitalised, examples could be:

  •  
      ageNextBirthday
      getLoanBalance
      toString
      random


    Back to top

    basicline.gif (169 bytes)

    RITSEC - Global Campus
    Copyright © 1999 RITSEC- Middlesex University. All rights reserved.
    webmaster@globalcampus.com.eg