Have some structure, List
, LinkedList
, etc., that allows me to put two attributes in the cell? For example, an integer and a string in each cell.
Have some structure, List
, LinkedList
, etc., that allows me to put two attributes in the cell? For example, an integer and a string in each cell.
You would have to do something like this:
class MinhaEstutura {
public int MeuInteiro;
public String MinhaString;
}
The structure, in this case, would look like this:
ArrayList<MinhaEstrutura> lista = new ArrayList<MinhaEstrutura>();
Example
//Criação e Adição
Map<Integer, String> dic = new HashMap<>();
dic.put(1, "Nome 1");
dic.put(2, "Nome 2");
dic.put(3, "Nome 3");
dic.put(4, "Nome 4");
//Leitura de cada item adicionado
Iterator<Map.Entry<Integer,String>> itr = dic.entrySet().iterator();
while (itr.hasNext()){
Entry<Integer,String> item = itr.next();
System.out.println(item.getKey().toString() + " " + item.getValue());
}