5.标识符、基本数据类型(5. Identifier and basic data type)

标识符注意点

  • 所有标识符都应该以字母(A-Z或者a-z),美元符($)、或者下划线(_)开始
  • 首字符之后可以是字母(A-Z或者a-z),美元符($)、或者下划线(_)或数字的任何字符组合
  • 不能使用关键字作为变量名或方法名
  • 标识符是大小写敏感的
  • 不建议使用拼音和中文

八大基本数据类型:

  • 整型:

    byte :8位,数据范围是-128~127
    short :16位,数据范围-32768-32767
    int :32位,数据范围-231-231-1
    long :64位,数据范围-263-263-1

  • byte :8位,数据范围是-128~127
  • short :16位,数据范围-32768-32767
  • int :32位,数据范围-231-231-1
  • long :64位,数据范围-263-263-1
  • 浮点型:

    float :32位,数据范围在3.4e-45~1.4e38,赋值需加上F或f
    double :64位,数据范围在4.9e-324~1.8e308,赋值可以加d或D也可以不加

  • float :32位,数据范围在3.4e-45~1.4e38,赋值需加上F或f
  • double :64位,数据范围在4.9e-324~1.8e308,赋值可以加d或D也可以不加
  • 字符型:

    char :16位,存储单个字符,通过单引号赋值

  • char :16位,存储单个字符,通过单引号赋值
  • 布尔型:

    boolean :只有true和false

  • boolean :只有true和false
————————

Identifier considerations

  • All identifiers should be in letters (A-Z or A-Z), dollar sign ($), or underscore () start
  • The first character can be followed by a letter (A-Z or A-Z), a dollar sign ($), or an underscore () Or any character combination of numbers
  • Keywords cannot be used as variable or method names
  • Identifiers are case sensitive
  • Pinyin and Chinese are not recommended

Eight basic data types:

  • Integer:
    Byte: 8 bits, the data range is – 128 ~ 127
    Short: 16 bits, data range – 32768-32767
    Int: 32 bits, data range – 231-231-1
    Long: 64 bits, data range – 263-263-1
  • Byte: 8 bits, the data range is – 128 ~ 127
  • Short: 16 bits, data range – 32768-32767
  • Int: 32 bits, data range – 231-231-1
  • Long: 64 bits, data range – 263-263-1
  • Floating point:
    Float: 32 bits, the data range is 3.4e-45 ~ 1.4e38, and f or F shall be added to the assignment
    Double: 64 bits. The data range is 4.9e-324 ~ 1.8e308. The assignment can be added with or without D
  • Float: 32 bits, the data range is 3.4e-45 ~ 1.4e38, and f or F shall be added to the assignment
  • Double: 64 bits. The data range is 4.9e-324 ~ 1.8e308. The assignment can be added with or without D
  • character:
    Char: 16 bits, which stores a single character and is assigned by single quotation marks
  • Char: 16 bits, which stores a single character and is assigned by single quotation marks
  • 布尔型:

    boolean :只有true和false

  • boolean :只有true和false