Wednesday, July 29, 2015

Java : String Vs StringBuffer vs StringBuilder

Java : String Vs StringBuffer vs StringBuilder 

 

So suppose you declare a String object:
String myString = “Hello”;

Next, you want to append “Guest” to the same String. What do you do?
myString = myString + ” Guest”;

Result : “Hello Guest”.

Although we made use of the same object(myString), internally a new object was created in the process. So, if you were to do some string operation involving an append or trim or some other method call to modify your string object, you would really be creating those many new objects of class String.


Example :
        String s = "Let’s test";
        s.concat("if this works then the string is IMMUTABLE");
        System.out.println(s);
      
        s = s.concat("if the String object is not IMMUTABLE");
        System.out.println(s);

To Make String Operations more Efficient ?

Ans : By using StringBuffer/StringBuilder

StringBuffer and StringBuilder have the same methods with one difference and that’s of synchronization. StringBuffer is synchronized ie., multiThreading is possible in StringBuffer  , hence slower compared to StringBuilder.

Example :
StringBuffer st=new StringBuffer("ahsas");
st.append("123");
st.append(123);



Monday, July 20, 2015

Browsers : Download Chrome and FireFox Versions


Download Chrome and FireFox Versions


http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

http://ftp.freenet.de/pub/filepilot/fpt/internet/browser/