Created
January 29, 2015 09:12
-
-
Save ron623/3ea0946d5d5d7a95ff73 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
package stringTest; | |
/* | |
* String型とStringBuilder型の文字列連結の挙動比較クラス | |
*/ | |
public class UseMethodByStringParam { | |
public UseMethodByStringParam() { | |
// TODO 自動生成されたコンストラクター・スタブ | |
} | |
// String型文字列を引数とし、文字列連結をするメソッド。 | |
// 呼び出し元の文字列は変わらない。 | |
public void createString(String testString){ | |
// 文字列連結 | |
testString = testString + " メソッド内で付加した文字列"; | |
System.out.println(testString); | |
} | |
// StringBuilder型変数を引数とし、文字列連結をするメソッド。 | |
// 呼び出し元の文字列も変更される。 | |
public void createChangeString(StringBuilder sbr){ | |
// 文字列連結 | |
sbr = sbr.append(" メソッド内で付加した文字列"); | |
System.out.println(sbr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment