User 클래스
public class User { private int userNo; private String id; private String email; public int getUserNo() { return userNo; } public void setUserNo(int userNo) { this.userNo = userNo; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Override public String toString() { return "User [userNo=" + userNo + ", id=" + id + ", email=" + email + "]"; } }
Main 클래스
public class Main { public static void main(String[] args) { // Bean - 값을 가지고 있는 객체 User user = new User(); user.setUserNo(1); user.setId("admin"); user.setEmail("admin@naver.com"); System.out.println(user); } }
출력:
User [userNo=1, id=admin, email=admin@naver.com]