String 字符串常量StringBuffer 字符串变量(线程安全)StringBuilder 字符串变量(非线程安全)简要的说, String 类型和 StringBuffer 类型的主要性能区别其实在于 String 是不可变的对象, 因此在每次对 String 类型进行改变的时候其实都等同...
分类:
其他好文 时间:
2015-04-01 12:54:15
阅读次数:
75
在公司实习期间,慢慢的体会到了作为一名开发人员,公司的Code convention是多么的重要。下面一条便是公司列举出来的。1. Rather than “String”, “StringBuffer” is recommended to be used to concatenate char.....
分类:
编程语言 时间:
2015-04-01 11:19:25
阅读次数:
136
反转数字,考虑溢出的情况。直接返回零(好坑啊)。public class Solution { public int reverse(int x) { if(x == 0) return 0; StringBuilder sb = new St...
分类:
其他好文 时间:
2015-04-01 01:48:15
阅读次数:
131
二进制转换和字符串逆序。要考虑int的范围,测试数据是有溢出的。Math.pow是有精度损失的,最好写成整数的。public class ReverseBits { public static int reverseBits(int n) { StringBuilder...
分类:
其他好文 时间:
2015-04-01 01:40:34
阅读次数:
122
接上一篇文章继续说String类
六,字符串的删除
字符串的删除是通过Remove方法实现的,格式为:
(1)字符串.Remove(开始位置)
(2)字符串.Remove(开始位置,移除数)
其中,开始位置是指字符串的索引,是一个整数,且小于字符串的长度。第一种格式,是将字符串开始位置后的所有子子符删...
public int ExecuteSqlTran(Maticsoft.Model.SHWL_Stock model, Maticsoft.Model.SHWL_OutPutComponet model2) { StringBuilder strSql = ne...
分类:
数据库 时间:
2015-03-31 14:29:32
阅读次数:
189
上一篇文章新手学JAVA(二)----String类与StringBuffer类的区别中了解到,String的值是不可变的,这就导致
每次对String的操作都会生成新的String对象,不仅效率低下,而且大量浪费有限的内存空间,StringBuffer是可变
类,和线程安全的字符串操作类,任何对它指向的字符串的操作都不会产生新的对象。
StringBuffer类和String...
分类:
编程语言 时间:
2015-03-30 16:20:52
阅读次数:
213
时隔几分钟又来写一个题,这个应该算个水题。public class Solution { public String convertToTitle(int n) { StringBuilder ans = new StringBuilder(); ...
分类:
其他好文 时间:
2015-03-29 23:30:18
阅读次数:
142
Java,String,StringBuffer,StringBuilder
分类:
编程语言 时间:
2015-03-29 18:02:52
阅读次数:
148
给一字符串如a2bc3d1 转换成aabcbcbcd 1 String decode(String str) { 2 String word=""; 3 StringBuilder result=new StringBuilder(""); 4 f...
分类:
其他好文 时间:
2015-03-22 00:20:11
阅读次数:
154