- 浏览: 746450 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (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 1261http://bbs.csdn.net/topics/3902 ... -
一个基本问题关于引用的
2012-05-15 10:20 1126问: int a = 1; Integer b = new ... -
我對面向對象和過程的理解。
2012-05-02 08:30 1065我的一些理解。 面向过程,是对客观现象的描述,感觉是有一个上 ... -
stack and heap
2012-01-13 23:17 1050我觉得是根据应用方式 和本身特性 才将内存分区的,目的是提 ... -
program experience conclusion
2011-07-11 15:35 10621. check parameters for validit ... -
PreparedStatement's possible designated parameter
2011-04-29 13:45 985though it's nearly impossible t ... -
clean Log4j
2011-04-12 11:19 1064import org.apache.log4j.BasicCo ... -
about abstract class
2011-04-02 10:34 865yes, we do know abstract class ... -
cvs operations on linux
2011-03-25 09:40 1008http://www.linuxhowtos.org/Syst ... -
regex to exchange two parts
2011-03-24 17:09 1087public class Test { public ... -
About the database locking
2011-03-09 11:02 962http://en.wikipedia.org/wiki/Lo ... -
how to send soap message in java
2011-03-08 10:29 1894import java.io.BufferedReader; ... -
About ShutDownDemo
2011-03-07 15:02 980public class ShutdownDemo { p ... -
How do you know if an explicit object casting is needed
2011-02-24 16:33 1186通俗来讲,不可能将一只是猫的动物强转为狗 再说Graphic ... -
有关MimeUtility
2011-02-24 13:11 3360import java.io.UnsupportedEncod ... -
C#连接sql server 2008的一件2事
2011-02-24 09:01 2151once upon a time, i came upon o ... -
Shadowing, Overriding, Hiding and Obscuring
2011-02-22 15:15 1163当子类属性与父类属性重叠时 这种叫法上是shadowi ... -
JAXP usage
2011-02-16 16:07 1096import java.io.ByteArrayInputSt ... -
运行一个类,如果classpath中路径带空格就加双引号
2011-02-11 11:25 2805注意是这样加: java -cp .;"d:\my ... -
关于ClassPath中的current directory
2011-01-28 16:40 1152Given: 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
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 ...
【标题】:“beware ircd 源码”是指一种基于IRC(Internet Relay Chat)协议的服务器源代码,用于构建自定义的IRC网络服务。IRC是一种实时通讯协议,主要用于在线聊天和协作,允许用户创建频道并与其他用户进行交互...
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"通常暗示可能存在某种警告或需要注意的情况。在IT领域,这可能指的是与软件、安全或技术问题相关的警示。在这种情况下,标签“字体”为我们提供了更具体的线索,表明我们可能正在讨论一种特定的字体或者...
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 ...
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: ...
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 ...
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 下测试(但代码不是很依赖操作系统)。
小心忍者熊 这是一款玩家使用 xbox 或 ps4 控制器的游戏。 每个玩家都被安排在游戏的一个角落。 玩家很饿,所以他们的健康栏总是在减少。 为了度过高峰期,他们必须吃东西。 游戏中有两种食物:快餐和健康食品。...
mc-curseforge-api 是的,这是一个糟糕的包裹名称,但无论如何。 这个软件包应该使Minecraft Mods Curseforge API的处理变得容易得多。 只需Swift提出要求,您就可以开始了! 安装 使用纱线(显然更好) yarn add ...
一个针对CurseForge上Serilum的mod的问题和内容建议的中心。 您可以创建一个,如果你发现了一个bug,有一个功能的想法,想要说些什么,或者只是想请教一个问题。 请指定正确的标签,谢谢! :) 从2021年2月开始,我的...
在描述中提到的 "Beware of these scammers" 提醒我们注意,可能存在一些欺诈行为或者不法分子利用EMV Reader Writer SDK进行非法活动。这可能是由于该SDK的开源性质,导致了不道德的个人或组织可能尝试滥用它来复制...
1.3 Styleand Structure of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 How to ReadThis Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.5 Stateof the Art ...
Portability The Perceived Advantages of Portability The Business Case for Portability Creating Portable Applications The Matrix of Pain Beware the Promises You Make ...