小编Tem*_*rum的帖子

重载主方法是不好的做法吗?

我知道它的局限性,但是如果我只打算上课,比如说

public class GUIWindow
{
    static JFrame theGUI = new JFrame();

    public static void main(String[] args)
    {
        theGUI.setSize(900, 600);
        theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        theGUI.setLocationRelativeTo(null);
    }

    public static void main(Object obj)
    {
        String[] array = new String[1];

        main(array);

        theGUI.setTitle(obj.getClass().getName());
    }

    public static void main()
    {
        String[] array = new String[1];

        main(array);

        theGUI.setTitle(null);
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以调用创建一个特定大小的默认GUI窗口来测试多个应用程序,这是一件好事吗?

java

1
推荐指数
1
解决办法
172
查看次数

标签 统计

java ×1