Parcourir HashMap<String, Matrice>()
Bonjour tout le monde
J'ai déclaré:
Code:
1 2
| Map<String, Integer> map = new LinkedHashMap<String, Integer>();
Map<String, Matrice> matriceRemplie = new HashMap<String, Matrice>(); |
dont la classe Matrice est la suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public class Matrice {
private String gram;
private int fq1;
private int fq2;
public String getGram() {
return gram; }
public void setGram(String gram) {
this.gram = gram; }
public int getFq1() {
return fq1;}
public void setFq1(int fq1) {
this.fq1 = fq1;}
public int getFq2() {
return fq2;}
public void setFq2(int fq2) {
this.fq2 = fq2; }
public String toString() {
return this.gram + "\t" + this.fq1 + "\t" + this.fq2;}
} |
Je voudrais savoir comment je peux parcourir toute HashMap, pour chaque valeur de grame de la matrice je la cherche dans la map , si existe je mets la valeur d'existance sinon je met 0 .
La stucture que j'ai choisi à remplir c'est :
Code:
Map<String, Integer> vecteur = new LinkedHashMap<String, Integer>();
Merci :)