package lezione14; public class Studente { private String nome; private String cognome; private String matricola; private static int counter = 0; public Studente(String nome, String cognome) { this.nome = nome; this.cognome = cognome; this.matricola = String.valueOf(Studente.counter); // equivalente a 'Studente.counter + ""' (forzando il cast) ma piu' elegante :) Studente.counter++; } public String getNome() { return this.nome; } public String getCognome() { return this.cognome; } public String getMatricola() { return this.matricola; } }