String与常量池

这一篇主要还是记录一下String 对象的创建,通过一个个小例子总结一下

        String a = "1";
        String b = "1";

        System.out.println(a == b);

这个 a 和 b 取的都是 Constant pool 常量池,我们用javac看一下字节码文件。

javap -v StringJson 的执行结果,可以看到 String 1 取的都是 Constant pool 里的#2, 那程序的执行结果也很明确了, 为true。

public class com.zhangmen.redis.StringJson
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #6.#19         // java/lang/Object."<init>":()V
   #2 = String             #20            // 1
   #3 = Fieldref           #21.#22        // java/lang/System.out:Ljava/io/PrintStream;
   #4 = Methodref          #23.#24        // java/io/PrintStream.println:(Z)V
   #5 = Class              #25            // com/zhangmen/redis/StringJson
   #6 = Class              #26            // java/lang/Object
   #7 = Utf8               <init>
   #8 = Utf8               ()V
   #9 = Utf8               Code
  #10 = Utf8               LineNumberTable
  #11 = Utf8               main
  #12 = Utf8               ([Ljava/lang/String;)V
  #13 = Utf8               StackMapTable
  #14 = Class              #27            // "[Ljava/lang/String;"
  #15 = Class              #28            // java/lang/String
  #16 = Class              #29            // java/io/PrintStream
  #17 = Utf8               SourceFile
  #18 = Utf8               StringJson.java
  #19 = NameAndType        #7:#8          // "<init>":()V
  #20 = Utf8               1
  #21 = Class              #30            // java/lang/System
  #22 = NameAndType        #31:#32        // out:Ljava/io/PrintStream;
  #23 = Class              #29            // java/io/PrintStream
  #24 = NameAndType        #33:#34        // println:(Z)V
  #25 = Utf8               com/zhangmen/redis/StringJson
  #26 = Utf8               java/lang/Object
  #27 = Utf8               [Ljava/lang/String;
  #28 = Utf8               java/lang/String
  #29 = Utf8               java/io/PrintStream
  #30 = Utf8               java/lang/System
  #31 = Utf8               out
  #32 = Utf8               Ljava/io/PrintStream;
  #33 = Utf8               println
  #34 = Utf8               (Z)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=3, args_size=1
         0: ldc           #2                  // String 1
         2: astore_1
         3: ldc           #2                  // String 1
         5: astore_2
         6: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
         9: aload_1
        10: aload_2
        11: if_acmpne     18
        14: iconst_1
        15: goto          19
        18: iconst_0
        19: invokevirtual #4                  // Method java/io/PrintStream.println:(Z)V
        22: return
      LineNumberTable:

=================================== 分割线 =============================

        final String a = "1";
        String b = "1";

        System.out.println(a == b);

一个变量加了final,但是字节码看来的结果还是一样,都是放入 Constant pool 里的 #2 ,结果认为true

public class com.zhangmen.redis.StringJson
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #6.#19         // java/lang/Object."<init>":()V
   #2 = String             #20            // 1
   #3 = Fieldref           #21.#22        // java/lang/System.out:Ljava/io/PrintStream;
   #4 = Methodref          #23.#24        // java/io/PrintStream.println:(Z)V
   #5 = Class              #25            // com/zhangmen/redis/StringJson
   #6 = Class              #26            // java/lang/Object
   #7 = Utf8               <init>
   #8 = Utf8               ()V
   #9 = Utf8               Code
  #10 = Utf8               LineNumberTable
  #11 = Utf8               main
  #12 = Utf8               ([Ljava/lang/String;)V
  #13 = Utf8               StackMapTable
  #14 = Class              #27            // "[Ljava/lang/String;"
  #15 = Class              #28            // java/lang/String
  #16 = Class              #29            // java/io/PrintStream
  #17 = Utf8               SourceFile
  #18 = Utf8               StringJson.java
  #19 = NameAndType        #7:#8          // "<init>":()V
  #20 = Utf8               1
  #21 = Class              #30            // java/lang/System
  #22 = NameAndType        #31:#32        // out:Ljava/io/PrintStream;
  #23 = Class              #29            // java/io/PrintStream
  #24 = NameAndType        #33:#34        // println:(Z)V
  #25 = Utf8               com/zhangmen/redis/StringJson
  #26 = Utf8               java/lang/Object
  #27 = Utf8               [Ljava/lang/String;
  #28 = Utf8               java/lang/String
  #29 = Utf8               java/io/PrintStream
  #30 = Utf8               java/lang/System
  #31 = Utf8               out
  #32 = Utf8               Ljava/io/PrintStream;
  #33 = Utf8               println
  #34 = Utf8               (Z)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=3, args_size=1
         0: ldc           #2                  // String 1
         2: astore_2
         3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
         6: ldc           #2                  // String 1
         8: aload_2
         9: if_acmpne     16
        12: iconst_1
        13: goto          17
        16: iconst_0
        17: invokevirtual #4                  // Method java/io/PrintStream.println:(Z)V
        20: return
      LineNumberTable:

=================================== 分割线 =============================

        final String a = "1";
        final String b = "2";

        System.out.println(a + b);

两个变量都加了final,然后两个final相加,字节码展示 只有 Constant pool 只有一个 #18 12 的数字 ,说明jvm会将两个final合成一个。

public class com.zhangmen.redis.StringJson
  minor version: 0
  major version: 52
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Methodref          #6.#15         // java/lang/Object."<init>":()V
   #2 = Fieldref           #16.#17        // java/lang/System.out:Ljava/io/PrintStream;
   #3 = String             #18            // 12
   #4 = Methodref          #19.#20        // java/io/PrintStream.println:(Ljava/lang/String;)V
   #5 = Class              #21            // com/zhangmen/redis/StringJson
   #6 = Class              #22            // java/lang/Object
   #7 = Utf8               <init>
   #8 = Utf8               ()V
   #9 = Utf8               Code
  #10 = Utf8               LineNumberTable
  #11 = Utf8               main
  #12 = Utf8               ([Ljava/lang/String;)V
  #13 = Utf8               SourceFile
  #14 = Utf8               StringJson.java
  #15 = NameAndType        #7:#8          // "<init>":()V
  #16 = Class              #23            // java/lang/System
  #17 = NameAndType        #24:#25        // out:Ljava/io/PrintStream;
  #18 = Utf8               12
  #19 = Class              #26            // java/io/PrintStream
  #20 = NameAndType        #27:#28        // println:(Ljava/lang/String;)V
  #21 = Utf8               com/zhangmen/redis/StringJson
  #22 = Utf8               java/lang/Object
  #23 = Utf8               java/lang/System
  #24 = Utf8               out
  #25 = Utf8               Ljava/io/PrintStream;
  #26 = Utf8               java/io/PrintStream
  #27 = Utf8               println
  #28 = Utf8               (Ljava/lang/String;)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=3, args_size=1
         0: getstatic     #2                  // Field java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #3                  // String 12
         5: invokevirtual #4                  // Method java/io/PrintStream.println:(Ljava/lang/String;)V
         8: return
      LineNumberTable:
        line 11: 0
        line 12: 8
}

=================================== 分割线 =============================

        String a = "1";
        String b = "2";

        String c = "12";


        System.out.println(a + b == c);

这次加大难度,通过前面的例子,可以推测出 Constant pool 有三个变量 1 ,2 ,12 . a与b相加 实际是 StringBuilder相加,所以 StringBuilder相加出来的字符串不等于 c,执行为false

Constant pool:
   #1 = Methodref          #12.#25        // java/lang/Object."<init>":()V
   #2 = String             #26            // 1
   #3 = String             #27            // 2
   #4 = String             #28            // 12
   #5 = Fieldref           #29.#30        // java/lang/System.out:Ljava/io/PrintStream;
   #6 = Class              #31            // java/lang/StringBuilder
   #7 = Methodref          #6.#25         // java/lang/StringBuilder."<init>":()V
   #8 = Methodref          #6.#32         // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   #9 = Methodref          #6.#33         // java/lang/StringBuilder.toString:()Ljava/lang/String;
  #10 = Methodref          #34.#35        // java/io/PrintStream.println:(Z)V
  #11 = Class              #36            // com/zhangmen/redis/StringJson
  #12 = Class              #37            // java/lang/Object
  #13 = Utf8               <init>
  #14 = Utf8               ()V
  #15 = Utf8               Code
  #16 = Utf8               LineNumberTable
  #17 = Utf8               main
  #18 = Utf8               ([Ljava/lang/String;)V
  #19 = Utf8               StackMapTable
  #20 = Class              #38            // "[Ljava/lang/String;"
  #21 = Class              #39            // java/lang/String
  #22 = Class              #40            // java/io/PrintStream
  #23 = Utf8               SourceFile
  #24 = Utf8               StringJson.java
  #25 = NameAndType        #13:#14        // "<init>":()V
  #26 = Utf8               1
  #27 = Utf8               2
  #28 = Utf8               12
  #29 = Class              #41            // java/lang/System
  #30 = NameAndType        #42:#43        // out:Ljava/io/PrintStream;
  #31 = Utf8               java/lang/StringBuilder
  #32 = NameAndType        #44:#45        // append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  #33 = NameAndType        #46:#47        // toString:()Ljava/lang/String;
  #34 = Class              #40            // java/io/PrintStream
  #35 = NameAndType        #48:#49        // println:(Z)V
  #36 = Utf8               com/zhangmen/redis/StringJson
  #37 = Utf8               java/lang/Object
  #38 = Utf8               [Ljava/lang/String;
  #39 = Utf8               java/lang/String
  #40 = Utf8               java/io/PrintStream
  #41 = Utf8               java/lang/System
  #42 = Utf8               out
  #43 = Utf8               Ljava/io/PrintStream;
  #44 = Utf8               append
  #45 = Utf8               (Ljava/lang/String;)Ljava/lang/StringBuilder;
  #46 = Utf8               toString
  #47 = Utf8               ()Ljava/lang/String;
  #48 = Utf8               println
  #49 = Utf8               (Z)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=4, args_size=1
         0: ldc           #2                  // String 1
         2: astore_1
         3: ldc           #3                  // String 2
         5: astore_2
         6: ldc           #4                  // String 12
         8: astore_3
         9: getstatic     #5                  // Field java/lang/System.out:Ljava/io/PrintStream;
        12: new           #6                  // class java/lang/StringBuilder
        15: dup
        16: invokespecial #7                  // Method java/lang/StringBuilder."<init>":()V
        19: aload_1
        20: invokevirtual #8                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        23: aload_2
        24: invokevirtual #8                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        27: invokevirtual #9                  // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
        30: aload_3
        31: if_acmpne     38
        34: iconst_1
        35: goto          39
        38: iconst_0
        39: invokevirtual #10                 // Method java/io/PrintStream.println:(Z)V
        42: return
      LineNumberTable:

=================================== 分割线 =============================

        String a = "1";
        String b = "2";

        String c = "12";


        System.out.println((a + b).intern() == c);

但是这一次 我用 (a + b).intern(),intern是干嘛的?可以看方法的源码,大意就是当方法执行时,如果Constant pool已经有相同内容的字符串(通过equals(Object)方法比对),就直接返回pool里面的字符串; 如果没有,就先放进Constant pool,然后返回pool里面的字符串。所以,这个程序我们知道 程序执行必为true。

java.lang.String @NotNull 
public String intern()
Returns a canonical representation for the string object.
A pool of strings, initially empty, is maintained privately by the class String.
When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.
It follows that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.
All literal strings and string-valued constant expressions are interned. String literals are defined in section 3.10.5 of the The Java™ Language Specification.
Constant pool:
   #1 = Methodref          #13.#26        // java/lang/Object."<init>":()V
   #2 = String             #27            // 1
   #3 = String             #28            // 2
   #4 = String             #29            // 12
   #5 = Fieldref           #30.#31        // java/lang/System.out:Ljava/io/PrintStream;
   #6 = Class              #32            // java/lang/StringBuilder
   #7 = Methodref          #6.#26         // java/lang/StringBuilder."<init>":()V
   #8 = Methodref          #6.#33         // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   #9 = Methodref          #6.#34         // java/lang/StringBuilder.toString:()Ljava/lang/String;
  #10 = Methodref          #35.#36        // java/lang/String.intern:()Ljava/lang/String;
  #11 = Methodref          #37.#38        // java/io/PrintStream.println:(Z)V
  #12 = Class              #39            // com/zhangmen/redis/StringJson
  #13 = Class              #40            // java/lang/Object
  #14 = Utf8               <init>
  #15 = Utf8               ()V
  #16 = Utf8               Code
  #17 = Utf8               LineNumberTable
  #18 = Utf8               main
  #19 = Utf8               ([Ljava/lang/String;)V
  #20 = Utf8               StackMapTable
  #21 = Class              #41            // "[Ljava/lang/String;"
  #22 = Class              #42            // java/lang/String
  #23 = Class              #43            // java/io/PrintStream
  #24 = Utf8               SourceFile
  #25 = Utf8               StringJson.java
  #26 = NameAndType        #14:#15        // "<init>":()V
  #27 = Utf8               1
  #28 = Utf8               2
  #29 = Utf8               12
  #30 = Class              #44            // java/lang/System
  #31 = NameAndType        #45:#46        // out:Ljava/io/PrintStream;
  #32 = Utf8               java/lang/StringBuilder
  #33 = NameAndType        #47:#48        // append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  #34 = NameAndType        #49:#50        // toString:()Ljava/lang/String;
  #35 = Class              #42            // java/lang/String
  #36 = NameAndType        #51:#50        // intern:()Ljava/lang/String;
  #37 = Class              #43            // java/io/PrintStream
  #38 = NameAndType        #52:#53        // println:(Z)V
  #39 = Utf8               com/zhangmen/redis/StringJson
  #40 = Utf8               java/lang/Object
  #41 = Utf8               [Ljava/lang/String;
  #42 = Utf8               java/lang/String
  #43 = Utf8               java/io/PrintStream
  #44 = Utf8               java/lang/System
  #45 = Utf8               out
  #46 = Utf8               Ljava/io/PrintStream;
  #47 = Utf8               append
  #48 = Utf8               (Ljava/lang/String;)Ljava/lang/StringBuilder;
  #49 = Utf8               toString
  #50 = Utf8               ()Ljava/lang/String;
  #51 = Utf8               intern
  #52 = Utf8               println
  #53 = Utf8               (Z)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=4, args_size=1
         0: ldc           #2                  // String 1
         2: astore_1
         3: ldc           #3                  // String 2
         5: astore_2
         6: ldc           #4                  // String 12
         8: astore_3
         9: getstatic     #5                  // Field java/lang/System.out:Ljava/io/PrintStream;
        12: new           #6                  // class java/lang/StringBuilder
        15: dup
        16: invokespecial #7                  // Method java/lang/StringBuilder."<init>":()V
        19: aload_1
        20: invokevirtual #8                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        23: aload_2
        24: invokevirtual #8                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        27: invokevirtual #9                  // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
        30: invokevirtual #10                 // Method java/lang/String.intern:()Ljava/lang/String;
        33: aload_3
        34: if_acmpne     41
        37: iconst_1
        38: goto          42
        41: iconst_0
        42: invokevirtual #11                 // Method java/io/PrintStream.println:(Z)V
        45: return
      LineNumberTable:

=================================== 分割线 =============================

        final String a = "1";
        final String b = "2";

        String c = "12";


        System.out.println((a + b) == c);

送分题,前面说了 两个final java会在 Constant pool 合并成一个 常量,那么c也是Constant pool 里的常量,所以为true

Constant pool:
   #1 = Methodref          #6.#19         // java/lang/Object."<init>":()V
   #2 = String             #20            // 12
   #3 = Fieldref           #21.#22        // java/lang/System.out:Ljava/io/PrintStream;
   #4 = Methodref          #23.#24        // java/io/PrintStream.println:(Z)V
   #5 = Class              #25            // com/zhangmen/redis/StringJson
   #6 = Class              #26            // java/lang/Object
   #7 = Utf8               <init>
   #8 = Utf8               ()V
   #9 = Utf8               Code
  #10 = Utf8               LineNumberTable
  #11 = Utf8               main
  #12 = Utf8               ([Ljava/lang/String;)V
  #13 = Utf8               StackMapTable
  #14 = Class              #27            // "[Ljava/lang/String;"
  #15 = Class              #28            // java/lang/String
  #16 = Class              #29            // java/io/PrintStream
  #17 = Utf8               SourceFile
  #18 = Utf8               StringJson.java
  #19 = NameAndType        #7:#8          // "<init>":()V
  #20 = Utf8               12
  #21 = Class              #30            // java/lang/System
  #22 = NameAndType        #31:#32        // out:Ljava/io/PrintStream;
  #23 = Class              #29            // java/io/PrintStream
  #24 = NameAndType        #33:#34        // println:(Z)V
  #25 = Utf8               com/zhangmen/redis/StringJson
  #26 = Utf8               java/lang/Object
  #27 = Utf8               [Ljava/lang/String;
  #28 = Utf8               java/lang/String
  #29 = Utf8               java/io/PrintStream
  #30 = Utf8               java/lang/System
  #31 = Utf8               out
  #32 = Utf8               Ljava/io/PrintStream;
  #33 = Utf8               println
  #34 = Utf8               (Z)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=4, args_size=1
         0: ldc           #2                  // String 12
         2: astore_3
         3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
         6: ldc           #2                  // String 12
         8: aload_3
         9: if_acmpne     16
        12: iconst_1
        13: goto          17
        16: iconst_0
        17: invokevirtual #4                  // Method java/io/PrintStream.println:(Z)V
        20: return
      LineNumberTable:

=================================== 分割线 =============================

        final String a = "1";
        String b = "2";

        String c = "12";


        System.out.println((a + b) == c);

少了一个final,final + 非 final变量 仍使用 StringBuilder 连接,跟 Constant pool里的12仍是两个东西。

 Constant pool:
   #1 = Methodref          #12.#25        // java/lang/Object."<init>":()V
   #2 = String             #26            // 1
   #3 = String             #27            // 12
   #4 = Fieldref           #28.#29        // java/lang/System.out:Ljava/io/PrintStream;
   #5 = Class              #30            // java/lang/StringBuilder
   #6 = Methodref          #5.#25         // java/lang/StringBuilder."<init>":()V
   #7 = Methodref          #5.#31         // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   #8 = String             #32            // 2
   #9 = Methodref          #5.#33         // java/lang/StringBuilder.toString:()Ljava/lang/String;
  #10 = Methodref          #34.#35        // java/io/PrintStream.println:(Z)V
  #11 = Class              #36            // com/zhangmen/redis/StringJson
  #12 = Class              #37            // java/lang/Object
  #13 = Utf8               <init>
  #14 = Utf8               ()V
  #15 = Utf8               Code
  #16 = Utf8               LineNumberTable
  #17 = Utf8               main
  #18 = Utf8               ([Ljava/lang/String;)V
  #19 = Utf8               StackMapTable
  #20 = Class              #38            // "[Ljava/lang/String;"
  #21 = Class              #39            // java/lang/String
  #22 = Class              #40            // java/io/PrintStream
  #23 = Utf8               SourceFile
  #24 = Utf8               StringJson.java
  #25 = NameAndType        #13:#14        // "<init>":()V
  #26 = Utf8               1
  #27 = Utf8               12
  #28 = Class              #41            // java/lang/System
  #29 = NameAndType        #42:#43        // out:Ljava/io/PrintStream;
  #30 = Utf8               java/lang/StringBuilder
  #31 = NameAndType        #44:#45        // append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  #32 = Utf8               2
  #33 = NameAndType        #46:#47        // toString:()Ljava/lang/String;
  #34 = Class              #40            // java/io/PrintStream
  #35 = NameAndType        #48:#49        // println:(Z)V
  #36 = Utf8               com/zhangmen/redis/StringJson
  #37 = Utf8               java/lang/Object
  #38 = Utf8               [Ljava/lang/String;
  #39 = Utf8               java/lang/String
  #40 = Utf8               java/io/PrintStream
  #41 = Utf8               java/lang/System
  #42 = Utf8               out
  #43 = Utf8               Ljava/io/PrintStream;
  #44 = Utf8               append
  #45 = Utf8               (Ljava/lang/String;)Ljava/lang/StringBuilder;
  #46 = Utf8               toString
  #47 = Utf8               ()Ljava/lang/String;
  #48 = Utf8               println
  #49 = Utf8               (Z)V
{
  public com.zhangmen.redis.StringJson();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=4, args_size=1
         0: ldc           #2                  // String 1
         2: astore_1
         3: ldc           #3                  // String 12
         5: astore_3
         6: getstatic     #4                  // Field java/lang/System.out:Ljava/io/PrintStream;
         9: new           #5                  // class java/lang/StringBuilder
        12: dup
        13: invokespecial #6                  // Method java/lang/StringBuilder."<init>":()V
        16: aload_1
        17: invokevirtual #7                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        20: ldc           #8                  // String 2
        22: invokevirtual #7                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
        25: invokevirtual #9                  // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
        28: aload_3
        29: if_acmpne     36
        32: iconst_1
        33: goto          37
        36: iconst_0
        37: invokevirtual #10                 // Method java/io/PrintStream.println:(Z)V
        40: return
      LineNumberTable:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值