'Jakarta Commons toString Builder'에 해당되는 글 1건

  1. 2010.02.19 Jakarta Commons toString Builder
카테고리 없음2010. 2. 19. 16:21
반응형
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

public class Main {
  private String id;

  private String firstName;

  private String lastName;

  public Main() {
  }

  public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", id).append(
        "firstName", firstName).append("lastName", lastName).toString();
  }

  public static void main(String[] args) {
    Main example = new Main();
    example.id = "1";
    example.firstName = "First Name";
    example.lastName = "Last Name";

    System.out.println("example = " + example);
  }
}

Posted by 1010