Array of Images Error (loading of images)

If I run what you wrote it highlights PImage[] img = new PImage[filenames.length];
and gives me NullPointerException error.