내 해시 맵에서 null 값을받습니다.Java hashmap이 null을 반환합니다.
private HashMap<String,Bitmap> thumbs = new HashMap<String,Bitmap>();
/* adding a single value to the hashmap */
가 그럼 난과 같이, 해시 맵에서 값을 불러 오는으로 진행 :이 해시 맵의 창조
public Bitmap getImageByFileName(String fileName) {
Bitmap fish = null;
Iterator it = thumbs.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
fish = (Bitmap)thumbs.get(fileName);
it.remove();
}
Log.i("shnitzel", " bitmap is " + fish);
fish = (Bitmap)thumbs.get(fileName);
Log.i("shnitzel", " final bitmap is " + fish);
return fish;
}
로그 파일 :
08-05 22:18:28.170: I/shnitzel(477): bitmap is [email protected]
08-05 22:18:28.170: I/shnitzel(477): final bitmap is null
당신이 볼 수 있듯이, 나는 'while'루프 내/외부에서 똑같은 명령을 사용하지만, 어떤 이유로 내부에서 작동하지만 외부에서는 작동하지 않습니다. 왜 이런 일이 생길까요?
while 루프에서 제거하지 않습니까? –
:( 실제로 당황 스럽네요. 실제로 왜 루프가 시작될 때 null 값을 받았는지 확인할 때까지 추가했습니다. 나는 솔직히 왜 이전에 작동하지 않았는지 모르겠지만, 지금은 어쨌든 고마워요. –
기쁜 문제가 해결되었다는 말을 듣고! 질문을 종료 할 대답을 선택하십시오. –