Java's basic grammar (1)

1. Keyword

  Java is given a particular meaning of the word (all lowercase words)

  const and goto as a reserved word, do not currently use.

  

 

 

 

2. Identifier

  Is my i themselves to classes, interfaces, methods, variables from the name.

  Composition rules:

    May uppercase and lowercase letters, numbers, $, and _ (underscore) by the English composition.

  note:

    You can not start with a number, not as Java keywords, strict distinction between the English case, the identifier without spaces.

 

3.java naming convention

  Common naming rules: See name EENOW

    Package (that is, the folder for the class with the same name to distinguish): Words All lowercase domain name written backwards

      Packet into a single stage and multi-stage packet (with intermediate. Separated )

 

    Class or interface : it may be by one or more word-word

      When a word: the first letter of the word capitalized

      When more than one word: the first letter of each word capitalized

 

    Method or variables : may be by one or more word-word

      When a word: word in all lowercase letters 

      When more than one word: the beginning of each word from the second word capitalized

 

    Constants : You can also by one word or more words

      When a word: a word in CAPITAL LETTERS

      When more than one word: words in CAPITAL LETTERS, in the middle of words separated by _

 

4. Comment

  Text explanation for the program, annotated text will not be JVM (Java Virtual Machine) to explain the implementation.

  Debugger can also help us to find errors in the code.

  Divided into:

  Single-line comments: // comment text

  Multi-line comments: / * comment text * /

  文档注释:/** 注释文字 */  (Java特有注释 可以用JDK提供的 javadoc 所解析,生成一个以网页形式体现的说明文档)

 

5.常量

  在程序执行的过程中,其值不发生改变的量。

  分类:

    字面值常量

      字符串常量:用双引号引起来的量

      字符常量:用单引号引起来的量(只可以是一个字母或一个汉字)

      整数常量:正整数 或 负整数

      小数常量:带小数点的数

      布尔常量:true 或 false

      空常量: null

    自定义常量(符号常量)

 

6.变量

  在程序运行的过程中,其值会发生改变的量。

Guess you like

Origin www.cnblogs.com/lzpsir/p/12115715.html