String Performance

Perhaps string concatenation is the most frequently used string operation in any language. In Java you can concat two string in this manner:

String concatdStr = "String1"+"String2"+" and String3";

But this is not a good idea. Behind the curtain , Java does string concatenation using StringBuffer class. So the above concat becomes :

String sBuf = new StringBuffer(32);
sBuf.append("String1").append("String2").append(" and String3");

Comments

Popular posts from this blog

Connect via SSH without a password from MacOS to Linux with an SSHKEY

Read and Write Files in Java

Install Mac OS on windows laptop