出一个关于JAVA String类型的题目

大家看看输出什么结果,先不要自己测试,对于理解String 存储知识还是不错,正确答案在本页自己找 ^_^

	public static void main(String[] args) {

		String a = "我试下String类 型";
		String c = a.replaceAll("\s+", "b");// if replace successfully,  return a new one
		String d = a.replaceAll("test", "b");// otherwise , return original reference

		if(a == "我试下String类 型"){
			System.out.println("aaa");
		} 

		if(c.intern() == "我试下String类b型"){			
			System.out.println("bbb");

		} 
		if(c == "我试下String类b型"){			
			System.out.println("ccc");
		} 

		if(d == "我试下String类 型"){
			System.out.println("ddd");
		} 
	}

输出: aaa bbb ddd

发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>