I'm getting a NullPointerException error when trying to run my program at this part:
File folder = new File("mypictures");
File[] pictures = folder.listFiles();
allCards = new Card[pictures.length];
for(int i=0; i < (pictures.length); i++){
allCards[i] = new Card(new ImageIcon(pictures[i].getPath()));
}
It complains on the follow line:
Card[] allCards = new Card[pictures.length];
listFiles()can returnnull. "Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs."NullPointerExceptionoccurs at runtime, not when compiling.