Ciao,
ho un problema che credo sia banale ma io non riesco ad uscirne fuori.
Ho una classe Studente:
Codice PHP:
public class Studente {

    
String matricola;
    
String nome;
    
String cognome;
    
String citta;

    
// Costruttore
    
public Studente(String unaMatricolaString unNomeString unCognomeString unaCitta){
        
this.matricola=unaMatricola;
        
this.nome=unNome;
        
this.cognome=unCognome;
        
this.citta=unaCitta;
    }
    
    public 
String getNome () {
        return 
nome;
    }

    public 
void setNome (String val) {
        
this.nome val;
    }

    public 
String getCognome () {
        return 
cognome;
    }

    public 
void setCognome (String val) {
        
this.cognome val;
    }

    public 
String getCitta () {
        return 
citta;
    }

    public 
void setCitta (String val) {
        
this.citta val;
    }
    public 
String getMatricola () {
        return 
matricola;
    }

    public 
void setMatricola (String val) {
        
this.matricola val;
    }

    
    @
Override
    
public String toString(){
        return 
"STAMPA INFO STUDENTE: "+matricola+" - "+nome+" - "+cognome+" - "+citta;
    }   

In un metodo di un altra classe ho un Set di oggetti di tipo Studente (praticamente usando la classe hashSet considerando che un Set non ammette doblicati):
[PHP]
HashSet<Studente> hashStudenti = new HashSet<Studente>();
[PHP]
Aggiungendo per due volte un studente (lo stesso studente), lo hashStudenti.size() diventa due piuttosto che uno come dovrei aspettarmelo visto che non si ammetono dublicati. Come mai? Quando è che due oggetti di tipo Studente sono uguali per hashSet?

Grazie in anticipo,
Gentjan