2011-11-18 2 views
0

얻기이 오류 :정수 호환되지 않는 Joda와 자바 랭

incompatible types 
    required: java.lang.Integer 
    found: java.util.Map.Entry<org.joda.time.DateTime.java.lang.Integer> 

및 오류의 결과 코드 :

public static void checkRange() { 

     DateTime startx = new DateTime(startDate.getTime()); 
     DateTime endx = new DateTime(endDate.getTime()); 

     //produces submap 
     Map<DateTime, Integer> nav = map.subMap(startx, endx); 

     //this is the line causing the error: 
     for (Integer capacity : map.subMap(startx, endx).entrySet()) { 

     } 
} 
} 

은의 startDate 및 종료 날짜 이전 다음 내가 유 여기에 변환 날짜로 정의 내가 한 DateTime을 볼 수 있습니다. 나는 그 문제 생각 해달라고지도 그것은 당신이 원하는 것 같아

public static TreeMap<DateTime, Integer> map = new TreeMap<DateTime, Integer>(); 

감사합니다,

답변

3

entrySet()은지도의 "행"즉 키와 값을 모두 포함하는 Entry 개체를 반환합니다. 값만 반복하려면이 경우 Integer의 모음 인 map.values()을 사용할 수 있습니다.

+0

브릴리언트 : D 오류가 없어져서 고맙습니다 ... 분명히 알지 못하는 좋은 설명입니다. –

2

map.subMap(startx, endx).values() 대신 map.subMap(startx, endx).entrySet()입니다.