Programming Tutorials

Comment on Tutorial - append() in Java By Jagan



Comment Added by : Mohamed firnaz

Comment Added at : 2011-12-07 04:54:27

Comment on Tutorial : append() in Java By Jagan
Excellent. I want you to publish about memory allocation for every sample programs side by side, as it plays a major role in live projects. For example :

public class stringmemory
{
public static void main(String[] args){
String str = "Sri seshaa";
String str1 = " Sri seshaa";
String str2 = str + str1 + " technologies";

StringBuffer s;
String d;
StringBuffer bufr = new StringBuffer(str);
s = bufr.append(str2);
d = String.valueOf(str);
System.out.println("......");
System.out.println(str2);
System.out.println("......");
System.out.println(d);
}
}

In this the memory allocated for concatenation in string class is more compared to the append operation in StringBuffer. Like this there are many advantages and disadvantages in it. Please publish it also, it will be helpful for the young programmers like me.


View Tutorial