Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Does immutable made String class more efficient?

class immutable String
0
10 Posted

Does immutable made String class more efficient?

0
10

No, Java String class is most famous for its inefficiency. All major coding guidelines (including Sun’s) will advise use less String class, and use StringBuffer instead. Since whenever you need do something on it, you actually need to build a new one, and put the old one for GC. String literal pooling is just a small remedy for a big disease. Read here for some of the ugliness of Java (String class included): The Java IAQ:Infrequently Answered Questions, read question 12, please. An empty new String() takes 40 bytes!!! That is why C# puts String as a value-type.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123