Each time the new operator is called, Java creates a new object

In Java, when we call a new constructor (), a new object will be created each time, that is; Allocate new memory or assume that many objects have been created for classes without any references

Therefore, Java can return objects marked as unassigned, or create a new object every time a new constructor () is called

My basic intention of asking this question is that if this happens, performance can be improved because the cost of creating new memory and destroying unrepaired objects will be reduced

Solution

Yes

Java never reuses objects

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>