je voudrai creer un ArrayList<ArrayList<Integer>> de dimention (n,m)
mais lorsque je veut acceder à une valeur il me donne NULL.POITEUR.EXCEPTION
pouvez vous m'aider

voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
     protected ArrayList<ArrayList<T>> mat;
 
    private int nbLig,nbCol;
 
...
 
    public X(int nbLig,int nbCol)
    {
         ArrayList<ArrayList> a;
         this.nbLig=nbLig;
         this.nbCol=nbCol;    
         a = new ArrayList<ArrayList>(nbLig);
 
         for(int i=0; i<nbLig;i++)
         {
                 a.add(new ArrayList<T>(nbCol));
         }
 
    }