gouf
12/21/2014 - 4:24 PM

make concatenated string using the StringBuilder

make concatenated string using the StringBuilder

class Main {
  public static void main(String[] args) {
    System.out.println(tag_for("h1", "Hello World!"));
    // => <h1>Hello World!</h1>
  }

  static StringBuilder tag_for(String tag_name, String body) {
    StringBuilder tag = new StringBuilder();

    tag.append("<");
    tag.append(tag_name);
    tag.append(">");

    tag.append(body);

    tag.append("</");
    tag.append(tag_name);
    tag.append(">");

    return tag;
  }
}