Qus:    What is difference between string and string builder?
Dec 11, 2020 15:08 2 Answers Views: 630 PADMAKEECHU

 String a =”GangBoard”;

String b =”Online Training”

Stirng C = a + b ;

it will create three separate memory in the Heap

Whereas

Stringbuilder s = new stringbuilder();

s.append(“GangBoard”);

s.append(“Online Training”);

//It will create single instance memory in the Heap

Prev Next
Answers (2)
PARTH Dec 12, 2020 02:50
Answer:   A string is immutable means you cannot change it after it was created. Any operation that appears to change the string instead returns a new instance whereas when you need a mutable string, such as where you need to change lots of things, you use a StringBuilder which is a buffer of characters that can be changed.

SHIVA Dec 12, 2020 08:23
Answer:   String a =”GangBoard”;
String b =”Online Training”
Stirng C = a + b ;
it will create three separate memory in the Heap
Whereas
Stringbuilder s = new stringbuilder();
s.append(“GangBoard”);
s.append(“Online Training”);
//It will create single instance memory in the Heap

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect