key ,value / getKey(), getValue(), containsKey();
import java.util.HashMap;
import java.util.Scanner;
public class HashMapEx {
public static void main(String[] args) {
HashMap map = new HashMap<>();
map.put("slow", "1234");
map.put("slow33", "0000");
map.put("kalpa", "1111");
Scanner sc = new Scanner(System.in);
int count =0;
while (count <= 10) {
System.out.println("ID를 입력하세요");
String id = sc.nextLine().trim();
System.out.println("Password를 입력하세요.");
String pass = sc.nextLine().trim();
if (!map.containsKey(id)) {
System.out.println("입력하신 ID가 없음");
continue;
}
if (!(map.get(id).equals(pass))) {
System.out.println("ID/Pass 다름");
continue;
} else {
System.out.println("정상 로그인");
System.exit(0);
}
count++;
}
}
}'kotlin > java' 카테고리의 다른 글
| Lambda 함수(1) (0) | 2023.01.06 |
|---|---|
| Collections class (0) | 2023.01.06 |
| TreeSet 예제 (0) | 2023.01.06 |
| Set, HashSet, equals, hashCode override 예제 (0) | 2023.01.06 |
| 무작위로 4개의 char를 추출해서 정렬 (0) | 2023.01.06 |