为什么我会收到此错误

dav*_*ave 0 java

我为什么会收到错误.在eclipse中,它表示构造函数调用应该是第一行.这是第一线.或者你不能扩展Main?

import javax.swing.JFrame;
import javax.swing.JLabel;

    public class Main extends JFrame{

        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            //JLabel testLabel1 = new JLabel();
            public Main(){
                super("title bar");
            }
        }

    }
Run Code Online (Sandbox Code Playgroud)

Chr*_*ung 5

你的Main构造函数应该坐在外面的的main方法.像这样:

public class Main extends JFrame {
    public Main() {
        super("title bar");
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //JLabel testLabel1 = new JLabel();
    }
}
Run Code Online (Sandbox Code Playgroud)