关于String操作的一个小例子
2009-04-24 00:36
471 查看
public class StringOperation { private static final String A; private static final String B; static { A = "ab"; B = "c"; } public static void main(String[] args) { //false String s = "abc"; String s1 = "ab"; String s2 = "c"; String s3 = s1 + s2; System.out.println(s==s3); //true String s4 = "abc"; System.out.println(s==s4); //true String s5 = "a" + "bc"; System.out.println(s==s5); //false String s6 = "a".concat("bc"); System.out.println(s==s6); //true final String s7 = "ab"; final String s8 = "c"; String s9 = s7 + s8; System.out.println(s==s9); //true String s10 = s; System.out.println(s==s10); //false String s11 = getPrefix() + "bc"; System.out.println(s==s11); //false String s12 = A + B; System.out.println(s==s12); //false String s13 = new String(new char[] { 'a', 'b', 'c', 'd' }); String s14 = s13.intern(); System.out.println(s13==s14); } private static final String getPrefix() { return "a"; } }
相关文章推荐
- 【转载】关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 高级操作
- 关于字符串操作的一个小例子(递归实现)
- 关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 高级操作
- js 关于操作超链接的一个例子
- 关于多线程的一个例子
- 照着网上做了一个小例子关于spring mvc
- 关于信号反射的仿真(针对《信号完整性分析》一书中的一个例子)
- 一个关于汽车的例子(C#面向对象编程)
- 一个PHP操作大变量的例子
- 一个关于异常的例子
- 对表格操作的一个javascript例子
- 一个关于php操作svn的功能类
- C# 串口操作系列(1) -- 入门篇,一个标准的,简陋的串口例子。
- 解决一个题目。关于结构体与链表的操作
- 关于Excel操作编写的一个软件设计构思案例[连载] --辅助功能:补全缺少数据、树定位、文本读与保存
- //4. 编写一个函数reverse_string(char * string)(递归实现) //实现:将参数字符串中的字符反向排列。 //要求:不能使用C函数库中的字符串操作函数。
- Q:java中关于String类型的一个问题
- 关于用DataTable.Select()方法出现“无法在 System.String 和 System.Int32 上执行“=”操作。”错误的原因
- js中关于map的增、删、改、查操作及其js中如何建立一个对象
- 一个通过BackgroundWorker实现WinForm异步操作的例子