继续转载当年的坑系列,这个系列的题目都是当年从各种坑中收集而来的。
本题中只要有跟final字符串有关的操作,最后结果都相等

false

true

true

true

true


                String ab = "ab";
			
	        String a = "a";
	        String b = a +"b";
	        System.out.println(b == ab);
	        
	        final String s12 = "a";
	        String s22 = s12 +"b";
	        System.out.println(s22 == ab);
	        
	        final String s1 = "ab";
	        String s4 = "abcdef";
	        String s5 = s1 + "cdef";
	        String s6 = "ab" + "cdef";
	        System.out.println(s4 == s5);
	        System.out.println(s4 == s6);
	        System.out.println(s5 == s6);

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required

This site uses Akismet to reduce spam. Learn how your comment data is processed.