About Java, those things I have doubts about (constantly updated ... )

Source: Internet
Author: User

This article mainly lists some of the common Java to make sure that people do not pay attention to the problem.

will continue to be updated, welcome attention ...

If you feel unreasonable, welcome to comment exchange, no sparks how impressed?

(1) is Java really a value pass? Or a reference pass?

Find out the problem is because some students said to start blogging, so he wrote how to blog: Java is the value of the pass? Or a reference pass? , say let me see.

I feel quite reasonable after reading, immediately to his reply said "good oh". Reasonable is reasonable, but according to his argument, what is not the value of the past Ah, is the value of delivery?

This morning to work, came earlier, Baidu a bit this problem, and then saw another article: Java: By value or by reference to pass the detailed explanation, inside the comment is a variety of tear force. Still don't get a unified answer AH.

See another article in the back: Java only by the value of the pass, not by reference! , as well as the comments corresponding to the article. I have my own opinion, too.

In general, "there are only basic types in Java, and strings that are defined in this way are passed by value (that is, the string is defined directly using double quotation marks: string str =" small Pigeon "), others are passed by reference. "It ought to be right."

Once a java.lang.String instance object is created, the sequence of characters it contains cannot be changed.

String is also passed as a reference copy, but because string is final, it is equivalent to passing by value.

In fact, by value or by reference is the difference between "whether the memory copy of the object at the time of delivery", the basic type in Java is because the storage area in the JVM is different from the ordinary object so that the transfer will be copied, pass the copied value, but the object is not copied at the time of delivery, direct "reference value", Points to the same piece of object heap memory area.

Constantly updated in .....

About Java, those things I have doubts about (constantly updated ... )

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.