StringBuffer使用append提示String concatenation as argument to 'StringBuffer.append()' call
2014-03-27 00:00
399 查看
昨天发现一个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.
这段英文看的意思不是很明白怎么回事,
代码大概是这样的后面还有很多 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 来写的话,那这段代码阅读起来可就要命了,所以还是忽略这个提示了
相关文章推荐
- StringBuffer使用append提示String concatenation as argument to 'StringBuffer.append()' call
- 使用GCC4.8 编译android内核提示warning: argument to ‘sizeof’ in ‘void* memset(void*, int, size_t)’
- 使用 toString.call()方法判断数据类型
- StringBuffer前后是null,StringBuffer.append()的情况
- 使用CURL上传文件和数据时提示Array to string conversion错误,解决方法!
- 使用GPS提示的问题是Call requires permission which may be rejected by user: code should explicitly check to s
- "String Concatenation vs String Builder - The performance hit! See it to believe it :o)"
- php使用curl函数提示Call to undefined function curl_init()
- StringBuilder vs String concatenation in toString() in Java
- Java String vs StringBuilder vs StringBuffer Concatenation Performance Micro Benchmark
- 字符串连接:使用StringBuffer#append来替代”+”真的会带来性能提升吗?
- Educational Codeforces Round 9-C. The Smallest String Concatenation(字符串排序)
- win7下非管理员用户使用sqlplus 10.2.0.1版本遇到的问题--SP2-1503: Unable to initialize Oracle call interface
- JavaScript中toStirng()与Object.prototype.toString.call()区别
- php7使用mysql扩展程序,Uncaught Error: Call to undefined function mysql_connect() in xxx
- String的兄弟姐妹和亲戚:StringBuilder,StringBuffer,StringReader,StringWriter,StringBufferInputStream
- Eclipse的JSP页面提示Multiple annotations found at this line或者String cannot be resolved to a type
- 回文解码---string.append() 和 string.insert() 的区别,substr() 的使用
- C - The Smallest String Concatenation CodeForces - 632C(按字典序列排列 )string或者数组
- C# System.DateTime.Now.ToString()使用注意事项