JAVA- basis - keywords, references, direct, variables, constants

A keyword
    java language-specific word java internally defined, these words have a special meaning, developers avoid these words in a special statement should define your own name. These special words to call java keywords.
    java total of 53 keywords, in addition const, goto keyword is two words, but no function is java reserved keywords.

  

Second, the identifier of the
    user-defined name it is called an identifier.
    Defined identifiers need to follow the following rules:

      Identifier can not be a keyword.
      Identifier can consist of letters, numbers, change the line (_), the dollar sign ($).
      Identifiers can not begin with a number.
      Identifier should have a clear meaning in the definition, and see to know the name of Italy.
      java recommended hump naming rules to define identifiers. This is the best practice java defined identifier.

    Hump ​​naming rules:

      An identifier may be stitched together by a plurality of words or a word.
      If the identifier is used as the name of the class / interface name is, the first letter of each word capitalized other letters lowercase.
      For example:
        UserService
        ProdService


      If the identifier as a variable name, the first word lowercase, followed by the word capitalized.
      For example:
        String userName = "ZS"
        int userIdNum = 3


      如果标识符用作常量名称,则所有单词全部大写,单词之间用下划线连接
      例如:
        final PI_NUM = 3.14


      专有缩写名词通常全部大写
      例如:
      String NBA = “nba”

三、引用、常量、变量、直接量

  引用:
    在java中通过引用来指向具体的数据。引用通过 [类型名 标识符] 来定义一个引用.
      int i = 10;
      final char c = 'a';
  常量:
    引用分为常量和变量
    所谓的常量指的是在程序执行过程中,不可以改变的引用。
    引用定义时用final修饰就是常量。
      final int i = 10;
      final char c = 'a';
  变量:
    引用分为常量和变量
    所谓的变量指的是在程序执行过程中,可以改变的引用。
    引用定义时不用final修饰就是变量。
    int i = 10;
    char c = 'a';
  直接量:
    基本数据类型及字符串类型的数据可以直接写下来使用,这样的量就称之为直接量。
    int i = 10;
    char c = 'a';
    String str = "abc";

Guess you like

Origin www.cnblogs.com/xiaoluohao/p/11304930.html