Tableau java
Fermé
ozerus
-
10 nov. 2011 à 15:02
KX Messages postés 16668 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 17 mars 2023 - 10 nov. 2011 à 16:45
KX Messages postés 16668 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 17 mars 2023 - 10 nov. 2011 à 16:45
A voir également:
- Tableau java
- Tableau croisé dynamique - Guide
- Jeux java itel ✓ - Forum Jeux vidéo
- Java runtime - Télécharger - Langages
- Tableau ascii - Guide
- Java apk - Télécharger - Langages
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
10 nov. 2011 à 16:45
10 nov. 2011 à 16:45
Tu dois créer une classe pour représenter tes données et faire un tableau d'objets de cette classe. Exemple :
class Personne
{
protected final String prenom;
protected final String nom;
public Personne(String prenom, String nom)
{
this.prenom=prenom;
this.nom=nom;
}
@Override
public String toString()
{
return prenom+" "+nom;
}
}
public class Test
{
public static void main(String...args)
{
Personne[] tableau = {new Personne("Albert","Einstein"), new Personne("Galileo","Galilei")};
for (int i=0; i<tableau.length; i++)
System.out.println(tableau[i]);
}
}