Why is this legal?:
public class TwoFrames extends JFrame {
public TwoFrames() {
return;
};
}
And this isn’t (NetBeans IDE saying invalid method declaration; return type required)?:
public class TwoFrames extends JFrame {
public firstFrame() {
return;
};
}
That is a constructor. It is called once the object is initialized. For example:
TwoFrames twoFrames = new TwoFrames();Unlike regular methods constructors does not return any value. Why should it?
Also, the constructor has to have the same name as the class.
Hope this helps you.