- 浏览: 728336 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (419)
- 杂软粉墨 (2)
- 创意灵感 (3)
- 经验记录 (137)
- 开源轨迹 (2)
- sip-communicator (2)
- 闲侃杂谈 (8)
- 问题交流 (24)
- 概念模式 (32)
- 难点备案 (5)
- JwChat (1)
- 中国象棋 (1)
- 教育探索 (6)
- 英语研究 (58)
- 星际争霸 (1)
- 电信知识 (1)
- 软件架构 (3)
- 哲学探索 (26)
- 算法灵魂 (8)
- 近视探索 (6)
- 数学数学 (3)
- 牛角钻尖 (23)
- 至强文言 (3)
- 数据结构 (1)
- 宇宙物理 (2)
- 网络架构 (3)
- 游戏领域 (4)
- 图形处理 (2)
- 修炼之路 (8)
- 读书天地 (20)
- 编解乱码 (2)
- 概念探索 (8)
- 格物致知 (1)
- 其它语言 (1)
- 测试领域 (3)
- 文化风流 (1)
- JQuery (1)
- 網頁領域 (1)
- Unix/Linux (1)
- Inside JVM (1)
- 异常分析 (1)
最新评论
-
suyujie:
引用
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
iamzhoug37:
您能说一下"局部变量不受文本顺序限制" 是 ...
声明前为什么能赋值却不能输出,都是使用
运行以下程序,看看两者的区别:
public class Test { String teststr = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; public static void main(String[] args) { new Test().go(); } public void go() { long start = System.currentTimeMillis(); statement0(); long end = System.currentTimeMillis(); System.out.println("UsedTime0 = " + (end - start)); start = System.currentTimeMillis(); statement1(); end = System.currentTimeMillis(); System.out.println("UsedTime1 = " + (end - start)); } // Inappropriate use of string concatenation - Performs horribly! public String statement0() { String result = ""; for (int i = 0; i < 100; i++) result += teststr; // String concatenation return result; } public String statement1() { StringBuilder b = new StringBuilder(1000 * teststr.length()); for (int i = 0; i < 1000; i++) b.append(teststr); return b.toString(); } }
在我机器上结果是:
UsedTime0 = 356
UsedTime1 = 1
字符串连接之所以这么慢是由于字符串是不可变的,每次连接都要复制两者的内容
Using the string concatenation operator repeatedly to concatenate n strings requires time quadratic in n.
The moral is simple: don’t use the string concatenation operator to combine
more than a few strings unless performance is irrelevant. Use StringBuilder’s
append method instead. Alternatively, use a character array, or process the strings
one at a time instead of combining them.
发表评论
-
关于方法访问控制符protected
2012-11-29 10:38 1198http://bbs.csdn.net/topics/3902 ... -
一个基本问题关于引用的
2012-05-15 10:20 1077问: int a = 1; Integer b = new ... -
我對面向對象和過程的理解。
2012-05-02 08:30 1011我的一些理解。 面向过程,是对客观现象的描述,感觉是有一个上 ... -
stack and heap
2012-01-13 23:17 1011我觉得是根据应用方式 和本身特性 才将内存分区的,目的是提 ... -
program experience conclusion
2011-07-11 15:35 10141. check parameters for validit ... -
PreparedStatement's possible designated parameter
2011-04-29 13:45 939though it's nearly impossible t ... -
clean Log4j
2011-04-12 11:19 1025import org.apache.log4j.BasicCo ... -
about abstract class
2011-04-02 10:34 809yes, we do know abstract class ... -
cvs operations on linux
2011-03-25 09:40 958http://www.linuxhowtos.org/Syst ... -
regex to exchange two parts
2011-03-24 17:09 1010public class Test { public ... -
About the database locking
2011-03-09 11:02 903http://en.wikipedia.org/wiki/Lo ... -
how to send soap message in java
2011-03-08 10:29 1854import java.io.BufferedReader; ... -
About ShutDownDemo
2011-03-07 15:02 921public class ShutdownDemo { p ... -
How do you know if an explicit object casting is needed
2011-02-24 16:33 1121通俗来讲,不可能将一只是猫的动物强转为狗 再说Graphic ... -
有关MimeUtility
2011-02-24 13:11 3298import java.io.UnsupportedEncod ... -
C#连接sql server 2008的一件2事
2011-02-24 09:01 2111once upon a time, i came upon o ... -
Shadowing, Overriding, Hiding and Obscuring
2011-02-22 15:15 1097当子类属性与父类属性重叠时 这种叫法上是shadowi ... -
JAXP usage
2011-02-16 16:07 1052import java.io.ByteArrayInputSt ... -
运行一个类,如果classpath中路径带空格就加双引号
2011-02-11 11:25 2762注意是这样加: java -cp .;"d:\my ... -
关于ClassPath中的current directory
2011-01-28 16:40 1115Given: 1. package com.company. ...
相关推荐
Item 63: Beware the performance of string concatenation Item 64: Refer to objects by their interfaces Item 65: Prefer interfaces to reflection Item 66: Use native methods judiciously Item 67: Optimize...
Hackers Beware The Ultimate Guide to Network Security.pdf
Beware
It's like a warning label that never fades, and it is a wake-up call for the world to beware of this expected darkness. This work is known as one of the most profound literary classics of the 20th ...
Correct use of header files can make a huge difference to the readability, size and performance of your code. The following rules will guide you through the various pitfalls of using header files. ...
Beware of these scammers
The TEMPLATE_STRING_IF_INVALID setting 171 Debug error pages 172 Database query history 176 Debug support in the development server 179 Handling problems in production 182 Creating general error ...
Item 5: Beware of Developing and Testing Based on an Existing System Chapter 2. Test Planning Item 6: Understand the Task At Hand and the Related Testing Goal Item 7: Consider the Risks Item 8: Base...
Beware of the BLOB! ■Chapter 27: Building a Content Provider First, Some Dissection Next, Some Typing Creating Your Content Provider Step 1: Create a Provider Class Step 2: Supply a Uri Step 3: ...
NFSv2 file types - beware, these are not the same in NFSv3.
建立一个属于自己的 IRC 服务器
and customers complained of the “spaghetti code” the Mac OS had become. On the other hand, underneath Mac OS X’s classy translucent desktop is Unix, the industrial-strength, rock-solid OS that ...
In any case, OS X Mountain Lion is the ninth major version of Apple’s Unix-based operating system. It’s got very little in common with the original Mac operating system, the one that saw Apple ...
17.7 BEWARE OF POLYMORPHIC CATCALLS! 636 17.8 AN ASSESSMENT 639 17.9 THE PERFECT FIT 640 17.10 KEY CONCEPTS STUDIED IN THIS CHAPTER 641 17.11 BIBLIOGRAPHICAL NOTES 641 Chapter 18: Global objects and ...
It seems to work correctly, but beware of BETA! Please, notify me, when Microsoft releases the final version of the SDK. Redistribution terms for this module consist of two parts. 1) wmamp.esp ...
Cave cavum 是一款使用 SDL 库用 C++ 编写的街机游戏。 只需要空格键就可以玩,它\\\\\\\ 很简单,但有时会让人上瘾。 仅在 GNU/Linux 下测试(但代码不是很依赖操作系统)。
"Beware the fallacies into which undisciplined thinkers most easily fall--they are the real distorting prisms of human nature." Chief among them: "Assuming more order than exists in chaotic nature." ...
小心忍者熊 这是一款玩家使用 xbox 或 ps4 控制器的游戏。 每个玩家都被安排在游戏的一个角落。 玩家很饿,所以他们的健康栏总是在减少。 为了度过高峰期,他们必须吃东西。 游戏中有两种食物:快餐和健康食品。...
mc-curseforge-api 是的,这是一个糟糕的包裹名称,但无论如何。 这个软件包应该使Minecraft Mods Curseforge API的处理变得容易得多。 只需Swift提出要求,您就可以开始了! 安装 使用纱线(显然更好) yarn add ...