Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/05/2015, 22:26
johannwesker
 
Fecha de Ingreso: mayo-2015
Mensajes: 3
Antigüedad: 8 años, 11 meses
Puntos: 0
Problema con arrrayList

hola me podrian ayudar con este problema, estoy jalando registros de una BD y guardandolos en nuevos objetos, despues los agrego al un arraylist, el problema esque cuando imprimio todo el arraylist, todos los registros son igual al ulitmo que se ingreso porfa me pueden ayuda?

<code>

private void obtieneMuestras()
{
ResultSet rs=c.getConsultaMuestra();
int vector[]=new int[8];
int i=0;
ArrayList<vectorCaracteristicas> temp=new ArrayList<>();
try {

while(rs.next())
{
vector[0]=rs.getInt("col1");
vector[1]=rs.getInt("col2");
vector[2]=rs.getInt("col3");
vector[3]=rs.getInt("col4");
vector[4]=rs.getInt("col5");
vector[5]=rs.getInt("col6");
vector[6]=rs.getInt("col7");
vector[7]=rs.getInt("col8");
vectorCaracteristicas vc=new vectorCaracteristicas(vector,rs.getInt("idusuario" ));
temp.add(vc);
}


} catch (SQLException ex) {
Logger.getLogger(Knn.class.getName()).log(Level.SE VERE, null, ex);
System.out.println("hubo error");
}

for (int j=0;j<temp.size();j++)
System.out.println(Arrays.toString(temp.get(j).get Vector())+" "+temp.get(0).getClase() +" c");

}
</code>