我用的IDE是jcreater,为什么在写main函数时
public static void main(String[] args)
运行时系统说:Exception in thread "main" java.lang.noSuchMethodError:main
而写成 public static void main(String args[])就能运行?可是在书上有的用的是
前者阿?而且把命令行看作是一个字符串数组定义的,符合规范阿?为何不行呢?
谢谢您的指教。
public static void main(String[] args)
运行时系统说:Exception in thread "main" java.lang.noSuchMethodError:main
而写成 public static void main(String args[])就能运行?可是在书上有的用的是
前者阿?而且把命令行看作是一个字符串数组定义的,符合规范阿?为何不行呢?
谢谢您的指教。
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;public class TimerTest{
public static void main(String args[]){
ActionListener listener=new TimerPrinter();
Timer t=new Timer(10000,listener);
t.start();
JOptionPane.showMessageDialog(null,"Quit program?");
System.exit(0);
}
}class TimerPrinter implements ActionListener{
public void actionPerformed(ActionEvent event){
Date now=new Date();
System.out.println("At the tone.the time is"+now);
Toolkit.getDefaultToolkit().beep();
}
}附上我的程序,我想不会是我的程序出现的问题。
两种写法没什么区别啊