Created
June 16, 2017 02:03
-
-
Save shybovycha/4e7b4d63613f9ffe9a61fd6b60ab70cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public java.lang.String concatenationWithExtraVar(); | |
Code: | |
0: new #8 // class java/lang/StringBuilder | |
3: dup | |
4: invokespecial #9 // Method java/lang/StringBuilder."<init>":()V | |
7: aload_0 | |
8: getfield #3 // Field a1:Ljava/lang/String; | |
11: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; | |
14: aload_0 | |
15: getfield #5 // Field a2:Ljava/lang/String; | |
18: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; | |
21: aload_0 | |
22: getfield #7 // Field a3:Ljava/lang/String; | |
25: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; | |
28: invokevirtual #11 // Method java/lang/StringBuilder.toString:()Ljava/lang/String; | |
31: astore_1 | |
32: aload_1 | |
33: areturn | |
public java.lang.String concatenationWithoutExtraVar(); | |
Code: | |
0: new #8 // class java/lang/StringBuilder | |
3: dup | |
4: invokespecial #9 // Method java/lang/StringBuilder."<init>":()V | |
7: aload_0 | |
8: getfield #3 // Field a1:Ljava/lang/String; | |
11: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; | |
14: aload_0 | |
15: getfield #5 // Field a2:Ljava/lang/String; | |
18: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; | |
21: aload_0 | |
22: getfield #7 // Field a3:Ljava/lang/String; | |
25: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; | |
28: invokevirtual #11 // Method java/lang/StringBuilder.toString:()Ljava/lang/String; | |
31: areturn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Chaining { | |
private String a1 = "111111111111111111111111"; | |
private String a2 = "222222222222222222222222"; | |
private String a3 = "333333333333333333333333"; | |
public String typicalChaining() { | |
return new StringBuilder().append(a1).append(a2).append(a3).toString(); | |
} | |
public String noChaining() { | |
StringBuilder sb = new StringBuilder(); | |
sb.append(a1); | |
sb.append(a2); | |
sb.append(a3); | |
return sb.toString(); | |
} | |
public String concatenationWithExtraVar() { | |
String result = a1 + a2 + a3; | |
return result; | |
} | |
public String concatenationWithoutExtraVar() { | |
return a1 + a2 + a3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment