I have a method where I read data from a DB, it goes like this:
public Collection<Map<String, String>> getAllFieldsValues() throws Exception
...
mapaTemp.put("DNI", dni.toString());
mapaTemp.put("NOMBRE", nombre.toString());
mapaTemp.put("APELLIDOS", apellidos.toString());
mapaTemp.put("CURSO", curso.toString());
mapaTemp.put("DIRECCION", direccion.toString());
allFieldsValues.add(mapaTemp);
...
return allFieldsValues;
Then I have another method to display the data in a JTable, but the problem is that I read it in a different order from what I put it, I read it in this order. DNI,DIRECCION,NOMBRE,APELLIDOS,CURSO.
This is a problem because when I display the data in the JTable it appears in wrong order. Anyone knows why can it be? Thanks!
What type is mapaTemp and how do you read the values from the map? For example a Java HashMap has no order so you cannot expect to get the results in insertion order.
You should be looking at a LinkedHashMap