Java ArrayList
Résolu/Fermé
A voir également:
- Java ArrayList
- Waptrick java football - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
- Jeux java itel football - Télécharger - Jeux vidéo
- Java jre - Télécharger - Langages
- Jeux java itel 5360 ✓ - Forum Mobile
2 réponses
merci, pour ceux que çà intéressent :
public Employe rechercherEmploye(String nom) {
for(int index=0;index<employes.size();index++) {
if(employes.get(index).getNom()==nom) return employes.get(index);
}
return null;
}
public Employe rechercherEmploye(String nom) {
for(int index=0;index<employes.size();index++) {
if(employes.get(index).getNom()==nom) return employes.get(index);
}
return null;
}
poukkid
Messages postés
106
Date d'inscription
mercredi 20 mai 2009
Statut
Membre
Dernière intervention
11 avril 2012
11
22 mai 2009 à 16:13
22 mai 2009 à 16:13
Salut,
Il faut que tu parcoures l'arraylist grâce à la fonction get(index) des arraylist (en incrémentant un compteur index jusqu'a arraylist.size() )
La fonction get(index) va te renvoyer le type d'objet que l'arraylist contient.
Pour chaque employé de ton arraylist tu dois donc comparer get(index).getNom() et "nom_de_l'employe_recherche".
Une fois que tu a trouvé deux chaines égales, tu as le bon employé dans get(index)
Vas voir la dessus pour plus d'infos :
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html
Il faut que tu parcoures l'arraylist grâce à la fonction get(index) des arraylist (en incrémentant un compteur index jusqu'a arraylist.size() )
La fonction get(index) va te renvoyer le type d'objet que l'arraylist contient.
Pour chaque employé de ton arraylist tu dois donc comparer get(index).getNom() et "nom_de_l'employe_recherche".
Une fois que tu a trouvé deux chaines égales, tu as le bon employé dans get(index)
Vas voir la dessus pour plus d'infos :
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html
22 nov. 2012 à 09:54