Je suis nouveau en programmation.Obtenir une exception NullPointerException - comment l'enlever?
array [row][col] = line.charAt(col);
^ce la ligne est là que je suis en train de NullPointerException
dans mon code. Comment l'enlever?
Scanner in = null;
try {
in = new Scanner(new FileReader("C:\\Documents and Settings\\UserXP\\My Documents\\src\\file.txt"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String line="";
ArrayList<String>arrayList=new ArrayList<String>();
while((line=in.nextLine())!=null) {
arrayList.add(line);
char [][] array = new char [2337][];
for (int row = 0; row<arrayList.size(); row++)
for(int col = 0; col<line.length(); col++) {
array [row][col] = line.charAt(col);
System.out.print(""+ array[row][col]);
}
System.out.println("");
}
//Close the input stream
in.close();
Je ne sais pas comment supprimer cette exception – user1172026
Pourquoi le nombre magique 2337? – adarshr
pls ajouter la trace de la pile à votre question ainsi – fmucar