[Help] Interfaccia Comparable
Posted by filipp8 on 03-02-2005 19:31
Per il progetto di info bisogna fare le classi Seme e Valore implementando l'interfaccia Comparable, giusto?
quindi devo ridefinire il metodo compareTo(Object o), giusto?
come mai allora, quando vado a fare il cast sull'object per ottenere un int mi dice che l'object è un "inconvertible types"?
questo è il metodo che ho scritto:
public int compareTo(Object obj)
{
int n = (int) obj;
if (s < n) return -1;
else if (s > n) return 1;
else return 0;
}
Powered by: vbHome (lite) v3.8 and vBulletin v2.3.1
Copyright © 2000 - 2002 Jelsoft Enterprises Limited