I'm new in Vector usage in Java , and the problem here is that a Vector is not showing the output expected (Correct output: Pollo - Ercole This code output Ercole - Ercole)
.
Class Dipendente
public class Dipendente
{
private String Id;
void setId(String exId)
{
Id=exId;
}
String getId()
{
return Id;
}
}
Class Azienda
public class Azienda
{
private Vector<Dipendente> Dip = new Vector<Dipendente>();
public static void main(String[] args) throws IOException
{
Azienda az = new Azienda();
az.dip.setId("Pollo");
az.Dip.add(az.dip);
az.dip.setId("Ercole");
az.Dip.add(az.dip);
//io.pf is System.out.println(strOut);
az.io.pf(az.Dip.get(0).getId());
az.io.pf(az.Dip.get(1).getId());
}
}
Correct output: Pollo - Ercole
This code output: Ercole - Ercole