filmov
tv
Core Java Interview question - For String manipulation String, StringBuffer or StringBuilder?

Показать описание
Click the below link to download the latest Billing System Source code.
More information about the Billing System Project. Watch this video
Everybody knows that String is an immutable class. if someone may not know about immutable. For those folks, I am explaining here about immutable. The general meaning of immutable is unchangeable. You can’t change that. So, the String object is unchangeable.
For Example.
String s1 = new String(“Suresh “); // here we are creating new String instance.
s1 = s1 + “Stalin ,”; // here we are creating new String instance.
s1 = s1 + “Steve Jobs “; // Again here we are creating new String Object for adding new value to s1
After creating a new instance of String Object, I am trying to modify the same string object. Yes, it is working perfectly and I am getting the expected output
But, the problem here is how appending is happening. When using the + operator each time, it is creating a new String object. In real-time we may get a scenario to append 1000 of String object or lacs of String object to append. This creates huge performance issues so that, all Java experts saying that we should not use String objects while appending data.
Java provides two utility classes to handle the String data. One is StringBuffer and another one is StringBuilder.
Detailed Text description please read following article for String vs StringBuffer vs StringBuilder
Committed code in the following git repository
I have posted all technical related topics on the following site. Please check it out
If you want to only Billing-System-related Technical Topics, please go to the following link.
Click the below link to download the latest Billing System code.
All Billing System-related videos update in the following post
#stringvsstringbuildervsstringbuffer #stringvsstringbuilder #stringvsstringbuffer #stringbuildervsstringbuffer #stringcodingpractice
More information about the Billing System Project. Watch this video
Everybody knows that String is an immutable class. if someone may not know about immutable. For those folks, I am explaining here about immutable. The general meaning of immutable is unchangeable. You can’t change that. So, the String object is unchangeable.
For Example.
String s1 = new String(“Suresh “); // here we are creating new String instance.
s1 = s1 + “Stalin ,”; // here we are creating new String instance.
s1 = s1 + “Steve Jobs “; // Again here we are creating new String Object for adding new value to s1
After creating a new instance of String Object, I am trying to modify the same string object. Yes, it is working perfectly and I am getting the expected output
But, the problem here is how appending is happening. When using the + operator each time, it is creating a new String object. In real-time we may get a scenario to append 1000 of String object or lacs of String object to append. This creates huge performance issues so that, all Java experts saying that we should not use String objects while appending data.
Java provides two utility classes to handle the String data. One is StringBuffer and another one is StringBuilder.
Detailed Text description please read following article for String vs StringBuffer vs StringBuilder
Committed code in the following git repository
I have posted all technical related topics on the following site. Please check it out
If you want to only Billing-System-related Technical Topics, please go to the following link.
Click the below link to download the latest Billing System code.
All Billing System-related videos update in the following post
#stringvsstringbuildervsstringbuffer #stringvsstringbuilder #stringvsstringbuffer #stringbuildervsstringbuffer #stringcodingpractice