Notes about value type and reference type

Source: Internet
Author: User
  Value Type Reference Type
Memory Allocation location Allocated in stack Allocated in heap
Efficiency High efficiency, no need for address translation Low Efficiency, requiring address translation
Memory reclaim Recycle immediately after use After use, do not recycle immediately, wait for GC to recycle
Assignment operation To create a new object with the same value. Only references the original object.
Function parameters and return values Is copying objects Is the reference of the original object and does not produce new objects
Type Extension Not easy to expand Easy to expand, convenient and Type Extension

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.