-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/test/java/com/ximo/datastructuresinaction/string/StringTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.ximo.datastructuresinaction.string; | ||
|
||
/** | ||
* @author xikl | ||
* @date 2020/5/26 | ||
*/ | ||
public class StringTest { | ||
|
||
public static void main(String[] args) { | ||
final String s = concatString("1", "2", "a"); | ||
System.out.println(s); | ||
} | ||
|
||
/** | ||
* <code> | ||
* // access flags 0x9 | ||
* public static concatString(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; | ||
* // parameter s1 | ||
* // parameter s2 | ||
* // parameter s3 | ||
* L0 | ||
* LINENUMBER 15 L0 | ||
* NEW java/lang/StringBuilder | ||
* DUP | ||
* INVOKESPECIAL java/lang/StringBuilder.<init> ()V | ||
* ALOAD 0 | ||
* INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder; | ||
* ALOAD 1 | ||
* INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder; | ||
* ALOAD 2 | ||
* INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder; | ||
* INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String; | ||
* ARETURN | ||
* L1 | ||
* LOCALVARIABLE s1 Ljava/lang/String; L0 L1 0 | ||
* LOCALVARIABLE s2 Ljava/lang/String; L0 L1 1 | ||
* LOCALVARIABLE s3 Ljava/lang/String; L0 L1 2 | ||
* MAXSTACK = 2 | ||
* MAXLOCALS = 3 | ||
* } | ||
* </code> | ||
* 会转化为StringBuilder来操作 | ||
* | ||
* @param s1 | ||
* @param s2 | ||
* @param s3 | ||
* @return | ||
*/ | ||
public static String concatString(String s1, String s2, String s3) { | ||
return s1 + s2 + s3; | ||
} | ||
|
||
|
||
|
||
} |