java - Which class to use for this static method, StringBuffer or StringBuilder? -


for following code, class should use in static method, stringbuilder or stringbuffer? based on api, stringbuffer thread-safe, stringbuilder not.

public static string getstring(int[] arrs) {     stringbuilder sb = new stringbuilder();  //1     stringbuffer sb = new stringbuffer();    //2     (int : arrs) {         sb.append(i);     }     return sb.tostring(); } 

it's method-local variable, won't have concurrent access there... use stringbuilder


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -