Character buffer: StringBuffer class, StringBuilder class

  StringBuffer class and String , as also used to represent a string, but due StringBuffer internal implementations and String different, StringBuffer during string processing, does not generate a new object in memory is superior to the use of String Class.

         So in actual use, if a string is often necessary to make changes, such as inserting, deleting, etc., use StringBuffer to be more suitable for some.

         In StringBuffer lot and there is class String class the same methods that are functionally and String class functions are exactly the same.

But one of the most notable difference is that, for StringBuffer object modification will change the object itself, and this is the String class the biggest difference.

         In addition, as StringBuffer is thread-safe, thread the concept of a special follow-up chapters are introduced, so in a multithreaded program can also be very convenient for use, but the efficiency of the program would be relatively little slower.

Guess you like

Origin www.cnblogs.com/qq1312583369/p/11101406.html
Recommended