java-basic data types differ from reference data types

Source: Internet
Author: User

1  Packagecom.liu.u6.copy1;2 /*3 * What is the difference between a basic data type and a reference data type4  */5  Public classSJLX {6      Public intAge ;7 }8  Packagecom.liu.u6.copy1;9  Public classTESTSJLX {Ten      Public Static voidMain (string[] args) { OneSystem.out.println ("*********************** basic data Type *********************8"); A         intNum1=3; -         intNum2=5; -System.out.println ("num1 Original value =" +num1); the         //assigns the value of the NUM1 to num2 -Num2=NUM1; -         //Modify the value of the num2 to see if the value of NUM1 is changed -Num2=8; +SYSTEM.OUT.PRINTLN ("num2 Modified, num1=" +num1); -System.out.println ("*********************** Reference data type *********************8"); +         //instantiate a pair of images ASJLX person1=NewSJLX (); atPerson1.age=23; -         //The assignment to the image is to assign the member variable to the past. -SJLX person2=Person1; -System.out.println ("Front ********" +person1.age); -Person2.age = 29; -System.out.println ("After ********" +person1.age); in          -     } to}

Result output:

java-basic data types differ from reference data types

Related Article

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.