「Java」StringBuilderクラスのappend()のサンプル

書式
public StringBuilder append(String str)
str – 文字列
戻り値:このオブジェクトへの参照
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.study;
public class StringbuilderDemo {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb.append(1234);
sb.append(true);
sb.append("abc");
System.out.println(sb.toString());
}
}
package com.arkgame.study; public class StringbuilderDemo { public static void main(String[] args) { StringBuilder sb = new StringBuilder(); sb.append(1234); sb.append(true); sb.append("abc"); System.out.println(sb.toString()); } }
package com.arkgame.study;

public class StringbuilderDemo {

      public static void main(String[] args) {
            StringBuilder sb = new StringBuilder();
            sb.append(1234);
            sb.append(true);
            sb.append("abc");
            System.out.println(sb.toString());
      }

}

実行結果
1234trueabc

Java

Posted by arkgame