User 클래스
package ex05_lombok; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder @ToString public class User { private int userNo; private String id; private String email; }
Main 클래스
public class Main { public static void main(String[] args) { User user1 = new User(); user1.setUserNo(1); user1.setId("admin"); user1.setEmail("admin@naver.com"); System.out.println(user1); User user2 = new User(1, "admin", "admin@naver.com"); System.out.println(user2); User user3 = User.builder() .userNo(1) .id("admin") .email("admin@naver.com") .build(); System.out.println(user3); } }
출력:
User(userNo=1, id=admin, email=admin@naver.com)
User(userNo=1, id=admin, email=admin@naver.com)
User(userNo=1, id=admin, email=admin@naver.com)