My code is :
public final class Pixels{
BufferedImage img=null;
public int w,h;
public Pixels(){
try {
// Read from a file
File file = new File("1.jpg");
img = javax.imageio.ImageIO.read(file);
}
catch (IOException e) { }
}
public void checkfunction(){
h=img.getHeight(); // errorpoint
w=img.getWidth();
}
Errors:
Exception in thread "main" java.lang.NullPointerException
at test.Pixels.<init> (Pixels.java:17)
Plz suggest my code!!!!!!