Forums Register Login

String Vs Stringbuffer

+Pie Number of slices to send: Send
To write SQL's which way of the following is better and why:

1. String query = "part1 of query"
query+ = "remaining query";

2. StringBuffer query.apend("part1 of query").append("remaining query");
+Pie Number of slices to send: Send
The compiler replaces String concatenation using + with StringBuffer.append(). If you're going to add up many pieces to make the query, using a StringBuffer directly will gain slight performance (very slight compared to running the query) over code clarity.
+Pie Number of slices to send: Send
Better go for Prepared statement instead of formatting the whole query ..
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 825 times.
Similar Threads
String vs MyStringBuffer.toString()
Regex vs manual implementation.
Concatenation of Strings using String vs. StringBuffer
String vs StringBuilder
UncaughtExceptionHandler vs Throwable Handler
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:11:46.