Identifiers and naming rules

Identifier:

       JAVA sequence of characters used for a variety of variables, methods and the like named elements become identifier.

       Tip: Those who own place from the name of the call identifier.

Define the legal rules for identifiers:

       1. The case of the 26 English letters, 0-9, or _ $ Composition

       2. The numbers can not begin with.

       3. Keywords and reserved words can not be used, but can contain keywords and reserved words

       4.Java strictly case-sensitive, unlimited length.

       The identifier can not contain spaces.

示例:miles,Test,a++,--a,4#R,$4,#44,apps,class,public,int,x,y,radius

 

 

Naming conventions:

Package name: multi-word when all letters are lowercase: xxxyyyzzz

Class name, interface name: multi-word, the first letter of all words capitalized: XxxYyyZzz

Variable names, method names: multi-word, lowercase first letter of the first word, the second word began to capitalize the first letter of each word: xxxYyyZzz

Constant name: All the letters are capitalized. When many words each word with an underscore: XXX_YYY_ZZZ

 

Note 1: When a name, in order to improve readability, to try to make sense, "see the name to know Italian."

Note 2: java using unicode character set, so the identifier can also use Chinese characters declaration, but not recommended.

 

 

Published 144 original articles · won praise 44 · views 130 000 +

Guess you like

Origin blog.csdn.net/u013294097/article/details/102146155