Faire votre propre classe 'Comparables'

J'ai suivi un tutoriel, mais a échoué à faire mon Country classe Comparable pour mon BST.

Principal:

BinarySearchTree A = new BinarySearchTree();
Country a = new Country("Romania", "Bucharest", 1112);
A.insert(a);

Catégorie de personnes de pays:

public int compareTo(Object anotherCountry) throws ClassCastException {
    if (!(anotherCountry instanceof Country))
        throw new ClassCastException("A Country object expected.");
    String anotherCountryName = ((Country) anotherCountry).getName();  
    int i = this.name.compareTo(anotherCountryName);
    if(i < 0){
        return -1;
    } else {
        return 0;
    }
}

erreur:

@Override
public int compareTo(Object anotherCountry) throws ClassCastException {
    if (!(anotherCountry instanceof Country))
      throw new ClassCastException("A Country object expected.");
    String anotherCountryName = ((Country) anotherCountry).getName();  
    return this.name.compareTo(anotherCountryName);

Description Resource    Path    Location    Type

Conflit de nom: La méthode compareTo(Object) de type Pays a le même effacement, compareTo(T) de type Comparable, mais ne pas le remplacer Country.java /Lab2_prob 4/src 17 Java Problème

Description Resource    Path    Location    Type
The method compareTo(Object) of type Country must override or implement a supertype method  Country.java    /Lab2_prob 4/src    line 17 Java Problem

et classe:

public class Country implements Comparable<Country>{
    private String name;
    private String capital;
    private int area;

Description Resource    Path    Location    Type

Le type de Pays doivent mettre en œuvre les hérité de la méthode abstraite Comparables.compareTo(Pays) Country.java /Lab2_prob 4/src 2 Java Problème

Est-ce que votre Country classe étendre Comparable<Country>?
Quel est le problème ou l'erreur êtes-vous réellement?
désolé il ajouté à l'erreur.

OriginalL'auteur Bogdan M. | 2012-10-24