Salve, vorrei che differenza c'è il metodo "setAut"e il metodo "public class Cd {}" in questo caso....
Visto che a quanto mi sembra entrambe servo ad assegnere un valore agli oggetti della classe Cd
Grazie...




public class Cd {
String autore;
int durata;

public Cd (String aut,int time){
this.autore=aut;
this.durata=time;

}

// metodi GET per accedere ad attributi privati
public String getAut (){
return this.autore;
}

public int getTime (){
return this.durata;
}

// metodi SET (qui inutili)
public void setAut (String aut){
this.autore=aut;;
}

public void setTime (int time){
this.durata=time;
}

static public void main (String []asd){

Cd [] Arraycd = new Cd [5];
//la durata degli album è quella originale
Arraycd[0]= new Cd("Californication",56);
Arraycd[1] = new Cd("Appetite for destruction", 53);
Arraycd[2] = new Cd("The wall",81);
Arraycd[3] = new Cd("Led Zeppelin IV",42);
Arraycd[4]= new Cd("Back in black",41);

int max=0, k=0;

for (int i=1; i<Arraycd.length; i++){
max=Arraycd[0].getTime();
if (Arraycd[i].getTime() > max) k=i;
}
System.out.println("Album con durata maggiore = "+Arraycd[k].getAut()+" , "+Arraycd[k].getTime()+" min");
}
}