Os:windows7 x64
Jdk:jdk-8u131-windows-x64
Ide:eclipse Oxygen Release (4.7.0)
Code
Package Jizuiku0;public class Demo11 {public static void main (string[] args) {String str1 = "Cnblog"; String str2 = str1 + "Jizuiku"; System.out.println (str1 = = str2); StringBuffer sb1 = new StringBuffer ("Cnblog");//create buffer a,a with cnblogstringbuffer SB2 = Sb1.append ("Jizuiku");// Append append to buffer A, buffer A is also buffer ASystem.out.println (SB1 = = SB2);//sb1, SB2 all point to buffer a}}
Result
Xjadcode (in order to find out what's going on here, use the Anti-compilation view):
Decompiled by Jad V1.5.8e2. Copyright 2001 Pavel kouznetsov.//Jad Home page:http://kpdus.tripod.com/jad.html//decompiler options:packimports (3) F Ieldsfirst ANSI Space//Source File Name: demo11.javapackage Jizuiku0;import Java.io.printstream;public class Demo11{public Demo11 () {}public static void Main (string args[]) {string str1 = "Cnblog"; String str2 = (New StringBuilder (String.valueof (STR1)). Append ("Jizuiku"). ToString (); System.out.println (str1 = = str2); StringBuffer sb1 = new StringBuffer ("Cnblog"); StringBuffer SB2 = sb1.append ("Jizuiku"); System.out.println (SB1 = = SB2);}}
Look at the anti-compiled code, (⊙o⊙) Oh, the original is so compiled, understand!
Java is good, worth learning.
Learning resources: CZBK's video library. If you have public resources, can share to me, with your resources to learn also can.
Blog post is to watch the video, into thinking written. It's good that the teacher speaks well. Blog bad, is to give the most bitter not serious.
JavaSE8 base StringBuffer and string variables after appending a string, the address of the reference variable changes