以下实例演示了通过两种方式创建字符串,并测试其性能:
StringComparePerformance.java 文件
以上代码实例输出结果为:
通过 String 关键词创建字符串 : 6 毫秒 通过 String 对象创建字符串 : 14 毫秒