Java ME/J2ME 환경에서 작동하도록 다음 코드를 얻고 싶습니다. 도와주세요 : 그것은 작동하지 않습니다항목 값 (키가 아님)을 기반으로 해시 테이블 정렬
Hashtable <Activity, Float>scores = new Hashtable<Activity, Float>();
scores.put(act1, 0.3);
scores.put(act2, 0.5);
scores.put(act3, 0.4);
scores.put(act5, 0.3);
Vector v = new Vector(scores.entrySet());
Collections.sort(v); //error is related to this line
Iterator it = v.iterator();
int cnt = 0;
Activity key;
Float value;
while(it.hasNext()){
cnt++;
Map.Entry e=(Map.Entry)it.next();
key = (Activity)e.getKey();
value = (Float)e.getValue();
System.out.println(key+", "+value);
}
, 나는 오류가 발생합니다 :
Exception in thread "main" java.lang.ClassCastException: java.util.Hashtable$Entry cannot be cast to java.lang.Comparable This points to the line that I've indicated with a comment in the code.
도와주세요, 그리고 명심 내가 J2ME를 사용하고 있습니다!