- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter53.java
More file actions
Latest commit
51 lines (43 loc) · 1.53 KB
/
Copy pathChapter53.java
File metadata and controls
51 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
packagechapter53;
importjava.util.ArrayList;
importjava.util.Scanner;
classMember1{
Stringid,password;
//기본 생성자
Member1(){}
publicStringgetId() {
returnid;
}
publicvoidsetId(Stringid) {
this.id = id;
}
publicStringgetPassword() {
returnpassword;
}
publicvoidsetPassword(Stringpassword) {
this.password = password;
}
}
publicclassArrayListEx1 {
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
//제네릭 설정 : Member1 클래스의 객체만 돌아온다
ArrayList<Member1> join = newArrayList<Member1>();
Member1member = newMember1();//Member1클래스의 객체 생성
Stringmemberid, memberpassword, memberpassword2;
join.add(member);//member 객체 넣기
System.out.println("1.회원가입");
System.out.println("아이디를 입력하세요");
memberid = sc.next();
//public void setId(String id) 함수 호출
member.setId(memberid);
System.out.println("비밀번호를 입력하세요");
memberpassword = sc.next();
//public void setPassword(String password)함수 호출
member.setPassword(memberpassword);
//setter / getter 함수로 대입한 join.add(member)로 넣어준 객체 데이터 갓 확인
System.out.println(join.get(0).getId());
System.out.println(join.get(0).getPassword());
System.out.println("---------------------------------");
}
}