Difference between String and String Buffer

String
=====
String are immutable object.Its value cannot be changed(constant).String object are readonly.If you create one instance of string and change the value of string then it create new instance.

String Buffer
=========
String Buffer is mutable.Its Value can be Changed.If you create one instance and append the text without creating a new instance

Example:
======
String
=====
String str=”welcome”;
str + = “to fordevs”;

String Buffer
=========
StringBuffer strbuff=new StringBuffer(“welcome”);
strbuff.append(“to fordevs”);

Both code give same output but Second approach much faster than first one.

Popularity: 6% [?]

Related posts:

  1. Encrypting string value using MD5 in PHP
  2. Make Textbox Number Only – WPF
  3. how to find a string within a string
  4. StringTokenizer in JAVA
  5. Palindrome For String And Numbers
You can leave a response, or trackback from your own site.

Leave a Reply

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars