기본 콘텐츠로 건너뛰기

자바 Set, Map

1.Set
HashSet<Integer> abc = new HashSet<Integer>();
abc.add(1);
abc.add(2);
abc.add(3);

Iterator it = abc.iterator();
Integer temp = 0;
while(it.hasNext()) {
temp = (Integer) it.next();
System.out.println(temp);
}

for(Integer item : abc) {
System.out.println(item);
}

2.Map
HashMap<String,Integer> abc = new HashMap<String,Integer>();
abc.put("a", 0);
abc.put("b", 1);
abc.put("c", 2);

for(String temp:abc.keySet()) {
System.out.println(temp);
}

if(abc.containsKey("a")) {
System.out.println(abc.get("a"));
}

abc.clear();
System.out.println(abc.size());

댓글

이 블로그의 인기 게시물

2017 암호경진대회 4번

가장 쉽게 풀었죠. 30분도 안걸렸던거 같네요. 프로그램을 통해서 암호문의 유효성이 검증되는데요, 역공학을 통해서 암호문을 쉽게 찾을 수 있습니다. 답안  : Snow White and the Seven Dwarfs!. 풀이  : Oracle 함수가  CRC 를 계산하기 위해서는 중간에 평문이 복구될 것으로 보였다 .  제공하는  dll 을 이용하여  Oracle 함수의 입력으로 암호문을 넣은 프로그램을 작성하였다 . IDA 와  Immunity Debugger 를 이용해 프로그램을 역공학하여 얻을 수 있었다 .