Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- boolean배열
- 마지막에 배열의 foreach구문이 틀린것같은데 ...... 저게왜틀린건지나는잘모르겠슴다.
- (참고로 boolean 배열의 default 값은 false 이다.
- 생활코딩
- 행열. 2중반복문..
- 그럼 int배열의 deefault값은?????
- ㅓㅂ
- while문이 틀린이유?? math.random()을 사용해서푸는법?
- form.getImageFies 오타났음
- bindingresult 쓰니까 에러났다. 어떻게해야하냐;;
- 출처:구멍가게코딩단-코배스(개정판)
Archives
- Today
- Total
푸린세스
chap12-08 HashMap<K,V> 본문
package ex12;
import java.util.HashMap;
public class Ex12_22 {
public static void main(String[] args) {
HashMap<String, Student2>map = new HashMap<>();
//JDK1.7부터 생성자에 타입지정 생략가능.
map.put("자바왕", new Student2("자바왕", 1, 1, 100, 100, 100));
System.out.println(map);
//{자바왕=ex12.Student2@49e4cb85}
//key , 뒤에것이 value <-toString 오버라이딩 안해서 이렇게 나타난것;
//map에서 꺼낼대
Student2 s = map.get("자바왕");
//원래 (Student) map.get(); 형변환필요했으나 지네릭클래스,타입정보주었기때문에
// public V get(Object key) { V가 Student2로..반환타입이 Studnet2로
System.out.println(s.name);
System.out.println(map.get("자바왕").name);
//위와 아래는 같은코드
}
}
class Student2{
String name = "";
int ban;
int no;
int kor;
int eng;
int math;
Student2(String name, int ban, int no, int kor, int eng, int math){
this.name = name;
this.ban = ban;
this.no = no;
this.eng = eng;
this.math = math;
}
}