joebar3333
Messages postés41Date d'inscriptiondimanche 24 octobre 2004StatutMembreDernière intervention29 juin 2005
-
23 mai 2005 à 19:07
cs_GodConan
Messages postés2113Date d'inscriptionsamedi 8 novembre 2003StatutContributeurDernière intervention 6 octobre 2012
-
23 mai 2005 à 20:18
salut,
voila je veux faire un tableau composé d'un type perso. Le problème est que je n'arrive pas à l'initialiser correctement.
Voila mon source :
public class monTab {
class monInfo{
boolean selected;
Color color;
}
private monInfo[] tabCartes;
private int typeOfCarte;
public monTab(int size, int type) {
tabCartes= new monInfo[size];
for(int i = 0; i < tabCartes.length; i++)
{
tabCartes[i].selected = false;
tabCartes[i].colo = Color.BLUE;
}
typeOfCarte = type;
}
}
Donc l'erreur se produit dans le constructeur de monTab, lorsque je veux affecter des valeurs à tabCartes. J'initialise mal tabCartes aparamment, mais je ne sais pas comment y rémédier.
Aidez moi please.
@+
A voir également:
Problème NullPOinterException dans un tableau perso
cs_GodConan
Messages postés2113Date d'inscriptionsamedi 8 novembre 2003StatutContributeurDernière intervention 6 octobre 201212 23 mai 2005 à 20:18
public monTab(int size, int type)
{
tabCartes= new monInfo[size];
for(int i = 0; i < tabCartes.length; i++)
{
//////////////////////
tabCartes[i] = new monInfo();
// indispensable d obtenir une reference valide avant d utilisé un objet... ;o)