This question already has an answer here:
public int compareTo(Tool b)
{
if(cost > b.cost)
return 1;
else if(cost == b.cost)
{
if(name.compareTo(b.name) < 0)
return 1;
else if(name.compareTo(b.name) == 0)
return 0;
else if(name.compareTo(b.name) > 0)
return -1;
}
else
return -1;
}
NetBeans gives an error at the last brace because "missing return statement". This is solved if I remove the "else", but shouldn't return -1
be the default codepath?
Aucun commentaire:
Enregistrer un commentaire