zoukankan      html  css  js  c++  java
  • StringBuffer使用append提示String concatenation as argument to 'StringBuffer.append()' call

    昨天发现一个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.     




    这段英文看的意思不是很明白怎么回事,

            str.append("Date: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "
    ");
            str.append("Version: " + info.versionName + "(" + info.versionCode + ")
    ");
    


    代码大概是这样的后面还有很多 append 。

    后来我才反应过来,是里面的参数的问题。

    本来  append 方法就是拼接字符串用的,而参数里面又用了 + 加号来拼接字符串,于是就提示你应该用 append 将这些字符串作为参数来使用~~~


    不过如果真的全用 append 来写的话,那这段代码阅读起来可就要命了,所以还是忽略这个提示了







  • 相关阅读:
    备份恢复八大核心
    ORACLE CentOS5.6安装
    ORA-00205
    sf02_选择排序算法Java与Python实现
    解决SQL命令行回退的问题
    redhat 6.4 yum 本地配置简记
    ORA-12705: Cannot access NLS data files or invalid environment specified
    asmca无法创建ASM磁盘
    Sort List
    Merge k Sorted Lists
  • 原文地址:https://www.cnblogs.com/zhouzme/p/5758456.html
Copyright © 2011-2022 走看看