JAVA basic type differs from reference type __java

Source: Internet
Author: User

Basic type: Basic type Naturally, it is a number, a character, or a Boolean value.

Reference type: Is an object type, what is the value. Its value is a reference to the memory space, which is the address that holds the variable represented in the memory of a


Base type passes are all values passed

Reference type passing belongs to the reference Pass, the reference type is the object type, but must not include string

reference passing and value passing

reference type: In addition to the function when passing a value is a "reference pass", in any "=" to the object variable to assign a value is "reference pass."

Value Delivery: The basic type of delivery is a value transfer, as in C language, when the basic data types of Java (such as int,char,double, etc.) as entry parameters to the function body, the incoming parameter in the function body into a local variable, This local variable is a copy of the input parameters, all functions within the body of the operation is for this copy of the operation, the function is finished, the local variable also completes its mission, it does not affect as input parameters of the variable. Parameter passing in this way is referred to as "value delivery."

/*define a class*/
class mydate{
    string  year;
    string  Mo nth;
    string  Day;
    string  Date;
    Public mydate () {
        year = "1900";
         Month = "01";
        day = "01";
        Date = year + "." + Month + "." + Day;
   }
     public String toString () {
        return Date;
   }    
}

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.