How to create characters in java
This article will explain in detail how to create characters in java. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
(1) if a string is created by direct assignment (String s = "xxx"), if there is no related string in the string constant pool, the string will be created in the string constant pool first, and then the reference address will be returned to the variable.
(2) if the new keyword is used to create an object, it will first determine whether the string exists in the string constant pool. If so, only create a string object on the heap and point to the string in the string constant pool. If the string is not changed in the string constant pool, two objects will be created. Create the string in the constant pool first, and then return the reference to the object on the heap.
On how to create characters in java to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.