Java keywords and identifiers

Keywords: computer languages previously defined, have special significance identifier.

  A total of 50 keywords, use can be divided into the following four categories:

    1. A data type;

   boolean、byte、char、 double、 false、float、int、long、new、short、true、void、instanceof。

    2. For statement;

  break、case、 catch、 continue、 default 、do、 else、 for、 if、return、switch、try、 while、 finally、 throw、this、 super。

    3. For the modification;

  abstract、final、native、private、 protected、public、static、synchronized、transient、volatile。

    4. For the methods, classes, interfaces, packages, and abnormal.

  class、 extends、 implements、interface、 package、import、throws。

Reserved words: In the new version of the JDK can be promoted to the keyword.

Identifier: programmer when defining Java program, custom some names.

  Naming rules:

    1. uppercase and lowercase letters, numbers, underscores, dollar symbols;

    2. Do not start with a number, not a keyword;

    3. strictly case-sensitive;

    4 can be any length.

  Precautions:

    1. folder (that package): all lowercase;

    2. The class or interface:

      A word: the first letter must be uppercase, such as: Student, Dog

      More than one word: the first letter of each word must be capitalized, such as: HelloWorld, StudentName

    The method or a variable:

      A word: the first letter lowercase, such as: main, age, sex

      More than one word: from the beginning of the second word, the first letter of each word in lowercase, such as: studentAge, showAllNames ()

    4. constants:

      A word: all caps, such as: PI

      More than one word: all uppercase, but between words separated by underscores, such as: STUDENT_MAX_AGE

 

Guess you like

Origin www.cnblogs.com/benon94/p/11575197.html