Skip to content

Tag: stringbuffer

If else condition with StringBuffer

I’m trying to make a If else condition to check if a current data exists on the database using a JSON request on a java application consuming a Rest Webservice. So, I want to receive a boolean or make a condition to verify what i’m receiving (normally, null or true/false) There’s a way to tr…

Most efficient way to concatenate Strings

I was under the impression that StringBuffer is the fastest way to concatenate strings, but I saw this Stack Overflow post saying that concat() is the fastest method. I tried the 2 given examples in Java 1.5, 1.6 and 1.7 but I never got the results they did. My results are almost identical to this Can somebod…

String vs StringBuffer. Tip of IDEA

Intellij Idea offers to replace the following: To: As far as I know it’s less effective (mutable/immutable). So, what’s better? Answer The second one compiles to the same byte-code as the first one, except it uses a non-synchronized StringBuilder instead of a synchronized StringBuffer. So it&#8217…