Summary of simple Java data types

Source: Internet
Author: User

Java Data types
    1. Basic data type (lowercase is generally used)

      • Characteristics
        1. In addition to the value without any identification, 1=1
        2. Immutable data types
        3. Within scope, local stacks are stored
        4. Low build costs
    2. Object data type (except for data types other than base data types)

      • Characteristics
        1. In addition to the value, there is an identity
        2. Partially variable
        3. In-heap storage, auto-recycle
        4. Generics for a unified representation
        5. High cost of building
      • Ancestor: A subclass of object (the default is the parent class is object)
    3. Wrapper classes for basic data types

      • Encapsulates the base data type as an object for operation
      • Use as little as possible and have less utility
      • Java automatically transforms the basic data types into basic data types
    4. Operator

      • "+" to complete the concatenation of strings
        1. Operator form
        2. The method form of the object
        3. function Form Math.sin ()
Static language and Dynamic language
  1. Java is a static language
    • Compile-time check
    • Python is a dynamic language, run-time check
  2. Static check
    • Bug check before running, compile-time check
    • Purpose: Avoid bugs that result from using the wrong type of operation
    • Content:
      1. Syntax error
      2. Wrong number of arguments
      3. Wrong parameter type
      4. return value Error
  3. Dynamic check
    • Checking when the program is running
    • Content
      1. Array out of bounds
      2. Null Object Call method
      3. The results are not clearly expressed.
  4. Static check for check type, dynamic check for value check
  5. The base data type may not show its original result
    • Overflow
    • The special value of the floating-point number represents nan,positive_infinity, negative_infinity
  6. Variability and immutability
    • Invariance:
      1. The value cannot be modified after the immutable data type creation is complete
      2. Invariant references, once the reference location is specified, cannot be specified again
      3. Final retouching to avoid errors and easy to understand
      4. notation
        • Final class cannot inherit
        • The final method cannot be overridden
        • Final variable cannot be modified
    • Variability:
      1. Modify without changing the direction of the variable, directly modify the data
    • Variability vs non-volatile
      1. Variable Type advantages:
        • Minimizing copy copies of variables
        • can be shared
      2. Variable type disadvantage: unsafe!
      3. aliases, alias
        • Different names but access to the same area can cause problems!
        • So you need to use defensive programming.
        • So in a variable data type you can use the following notation: return new DATE (End.modify ()), or clone
Snapshot chart
- 显式地表示模型    - 单线是可变的,双线是不可变的    - 不可变的引用指向可变的值
Complex data types
- 数组:    1. 数组一旦创建,长度不可以进行修改—>a.length().- 数组列表    1. 变长数组,只能放对象数据类型    2. List本身是一个接口,new时必须时要初始化具体实现,arraylist或linkedlist- 迭代器(Iterator)- 集合set 同样也只是一个接口    - 不允许重复 - 无序性- 表 MAP 接口++,键值对- Iteration 遍历器。 1. for each循环时隐式地使用Iterator
Immutable data types
    1. Packing class
      • You can control the user's use rights
      • So that the collection cannot be modified after it is established
null reference
    1. Null is the object data type that corresponds to the
    2. Careless use of NULL can cause problems
    3. The meaning of NULL is ambiguous

Summary of simple Java data types

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.