Hello everybody I have a problem with my code. On two lines (14 & 17) I get this error: cannot return a value from method whose result type is void.
But I don't have add void to my class.
Thanks in advance.
Greets
MeandJava
Here's my code:
package oop_po2;
import java.awt.Image;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
public class OOP_PO2_Test {
public ImageIcon(String filename){
java.net.URL imgURL = ImageIcon.class.getResource(filename);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + filename);
return null;
}
}
public Image getImage(String path){
Image image = null;
// TODO OOP_PO2_A1: Insert code here
return image;
}
public static void main(String args[]){
OOP_PO2_Test app = new OOP_PO2_Test();
Image image = app.getImage(""); // TODO OOP_PO2_A2: Fill in the path to an existing image
if(image != null && image instanceof Image){
System.out.println("Successfully loaded the image file.");
}
else{
System.out.println("Nothing loaded. Try again.");
}
}
}