Tuesday, September 10, 2013

String initialisation and concatenation in java

String initialisation and concatenation in java

In my application everything is working fine but I want to increase
performance and optimize my code.
which of these two is better for
1.initialisation
String str1=new String("Hello");
String str2="Hello";
2.concatenation
System.out.println(s1 + s2);
System.out.println(new StringBuffer(S1).append(s2));

No comments:

Post a Comment