[英]why String is designed Class/Object in Java, which uses more resources
Well, String is an often used type, working as an Object consumes more resource, why Sun designed it as an Object but not a simple variable like int 好吧,String是一种经常使用的类型,它作为对象工作会消耗更多的资源,为什么Sun将其设计为对象而不是像int这样的简单变量?
if someone says String can contain very long sentence, why it was not designed to be like int and Integer 如果有人说String可以包含很长的句子,为什么它的设计不像int和Integer
There are some advantage of being an Object instead of primitives 作为对象而不是基元有一些优点
如果您想更有效地将文本存储在内存中,可以将其保存在字节数组中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.