简体   繁体   中英

Stringbuilder inside loop efficiency?

Consider using something like

StringBuilder sb = new StringBuilder();
for(int i = 0; i < n; i++){
  sb.append('a');
}

Is the efficiency of the code O(N^2) or O(N) ?

它是O(N),这意味着要花n变量多大的代价。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM