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 自動生成されたコンストラクター・スタブ |
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
// String型文字列を引数とし、文字列連結をするメソッド。 | |
// 呼び出し元の文字列は変わらない。 | |
public void createString(String testString){ | |
// 文字列連結 | |
testString = testString + " メソッド内で付加した文字列"; | |
System.out.println(testString); | |
} |
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; | |
public class StringSample { | |
/* | |
* Object型の比較、String型の比較の挙動確認クラス | |
*/ | |
public StringSample() { |
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型の領域の使い方を学ぶためのクラス | |
*/ | |
public class StringPoolTest { | |
public StringPoolTest() { | |
// TODO 自動生成されたコンストラクター・スタブ |
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型の領域の使い方を学ぶためのクラス | |
*/ | |
public class StringPoolTest { | |
public StringPoolTest() { | |
// TODO 自動生成されたコンストラクター・スタブ |
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
// String型文字列を引数とし、文字列連結をするメソッド。 | |
// 呼び出し元の文字列は変わらない。 | |
public void createString(String testString){ | |
// 文字列連結 | |
testString = testString + " メソッド内で付加した文字列"; | |
System.out.println(testString); | |
} |
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
// String型引数の挙動確認 | |
UseMethodByStringParam stringPrm = new UseMethodByStringParam(); | |
String testString = "***渡す文字列***"; | |
// createStringメソッド内でtestString文字列の加工を行う | |
stringPrm.createString(testString); | |
// 引数として渡したtestStringがどうなったか確認 | |
System.out.println(testString); |
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
// StringBuilder型変数を引数とし、文字列連結をするメソッド。 | |
// 呼び出し元の文字列も変更される。 | |
public void createChangeString(StringBuilder sbr){ | |
// 文字列連結 | |
sbr = sbr.append(" メソッド内で付加した文字列"); | |
System.out.println(sbr); | |
} |
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
// 今度はStringBuilderでやってみる | |
StringBuilder sbr = new StringBuilder("***渡す文字列***"); | |
// createStringメソッド内でsbr文字列の加工を行う | |
stringPrm.createChangeString(sbr); | |
// 引数として渡したsbrがどうなったか確認 | |
System.out.println(sbr); |
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; | |
/* | |
* thisを使用したインスタンス変数へのアクセス確認クラス | |
*/ | |
public class thisTest { | |
public thisTest() { | |
// TODO 自動生成されたコンストラクター・スタブ |
OlderNewer