StringBuffer使用append提示String concatenation as argument to 'StringBuffer.append()' call
2014-03-07 13:52
471 查看
昨天发现一个IDE提示:
String concatenation as argument to 'StringBuffer.append()' call
less... (Ctrl+F1)
Reports String concatenation used as the argument to StringBuffer.append(),StringBuilder.append() orAppendable.append(). Such calls may profitably be turned into chained append calls on the existingStringBuffer/Builder/Appendable,
saving the cost of an extraStringBuffer/Builder allocation.
This inspection ignores compile time evaluated String concatenations, which when converted to chained append calls would only worsen performance.
![](https://img-blog.csdn.net/20140307135335937?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhvdXptZQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
这段英文看的意思不是很明白怎么回事,
代码大概是这样的后面还有很多 append 。
后来我才反应过来,是里面的参数的问题。
本来 append 方法就是拼接字符串用的,而参数里面又用了 + 加号来拼接字符串,于是就提示你应该用 append 将这些字符串作为参数来使用~~~
不过如果真的全用 append 来写的话,那这段代码阅读起来可就要命了,所以还是忽略这个提示了
String concatenation as argument to 'StringBuffer.append()' call
less... (Ctrl+F1)
Reports String concatenation used as the argument to StringBuffer.append(),StringBuilder.append() orAppendable.append(). Such calls may profitably be turned into chained append calls on the existingStringBuffer/Builder/Appendable,
saving the cost of an extraStringBuffer/Builder allocation.
This inspection ignores compile time evaluated String concatenations, which when converted to chained append calls would only worsen performance.
这段英文看的意思不是很明白怎么回事,
str.append("Date: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\n"); str.append("Version: " + info.versionName + "(" + info.versionCode + ")\n");
代码大概是这样的后面还有很多 append 。
后来我才反应过来,是里面的参数的问题。
本来 append 方法就是拼接字符串用的,而参数里面又用了 + 加号来拼接字符串,于是就提示你应该用 append 将这些字符串作为参数来使用~~~
不过如果真的全用 append 来写的话,那这段代码阅读起来可就要命了,所以还是忽略这个提示了
相关文章推荐
- android 文字或者图片生成.pdf文件
- Android开发之Intent.Action
- iOS 简单理解类的本质
- android APK签名汇总整理
- iOS学习系列 - 扩展机制category与associative
- android4.2源码编译调试出错
- Cocos2d-x教程(22)-lua中的json解析
- Android瀑布流照片墙实现,体验不规则排列的美感
- cocos2dx进度条CCProgressTimer使用的自定义函数
- Android照片墙应用实现,再多的图片也不怕崩溃
- android 开发入门(一)
- android 输入系统
- android APK签名过程之CERT.SF分析
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结
- cocos2d-x打包成apk时发生错误:Unable to add 'D:\cocos2d-x-2.2.2\cocos2d-x-2.2.2\projects\HelloWorld\proj.android\assets\CloseNormal.png': Zip add failed
- Android中图表AChartEngine学习使用与例子
- Android中图表AChartEngine学习使用与例子
- Android应用开发SharedPreferences存储数据的使用方法
- Android 进程和线程详解
- 编译Android4.4系统总结