Arraylist & Vector
Résolu/Fermé
Medd12
Messages postés
32
Date d'inscription
dimanche 6 avril 2014
Statut
Membre
Dernière intervention
13 février 2018
-
13 nov. 2016 à 14:03
Medd12 Messages postés 32 Date d'inscription dimanche 6 avril 2014 Statut Membre Dernière intervention 13 février 2018 - 13 nov. 2016 à 18:09
Medd12 Messages postés 32 Date d'inscription dimanche 6 avril 2014 Statut Membre Dernière intervention 13 février 2018 - 13 nov. 2016 à 18:09
A voir également:
- Arraylist & Vector
- Afficher arraylist java ✓ - Forum Java
- Trier arraylist java ✓ - Forum Programmation
- True vector internet monitor - Forum Windows
- Vector works mac - Télécharger - CAO-DAO
- Affichage des élément de ArrayList ✓ - Forum Java
1 réponse
KX
Messages postés
16668
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
17 mars 2023
3 005
13 nov. 2016 à 17:15
13 nov. 2016 à 17:15
Bonjour,
La documentation est faite pour ça :
Ne pas oublier la dernière ligne de description de Vector :
La documentation est faite pour ça :
- https://docs.oracle.com/javase/8/docs/api/index.html?java/util/ArrayList.html
- https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Vector.html
Ne pas oublier la dernière ligne de description de Vector :
it is recommended to use ArrayList in place of Vector
Modifié par KX le 13/11/2016 à 17:54
public class bibliotheque { private Ouvrage[]Tab; public bibliotheque(int n){ this.Tab= new Ouvrage[n]; } public int nbmax(){ return Tab.length; } public int nbOuvrage(){ int i=0; while(Tab[i] != null && i<nbmax()){ i++; } return i; } public boolean ajouterOuvrage(Ouvrage x){ int i=0; if(nbOuvrage()<nbmax()){ i=nbOuvrage(); Tab[i]=x; return true; } else { return false; } } public boolean supprimerOuvrage(Ouvrage x){ for(int i=0;i<nbOuvrage();i++){ if (Tab[i].equals(x)){ Tab[i]=Tab[nbmax()]; Tab[nbmax()]=null; return true;} } return false; } public boolean recherche(String titre){ for(Ouvrage o:Tab){ if(o instanceof Livre){ Livre l=(Livre)o; return l.gettitre().equals(titre); } else { if(o instanceof CD){ CD x=(CD)o; return x.gettitre().equals(titre); } } } return false; } public String toString(){ return(":"); } }13 nov. 2016 à 17:58
Plus d'infos : https://fr.wikibooks.org/wiki/Programmation_Java/Collections
13 nov. 2016 à 18:09