我觉得写测试程序先要清楚测试的目的 比如,我们要测一下jdk是否工作良好,可以写一个hello world
public class helloworld { public static void main(String[] args) { int i; i=2; System.out.println("hello!world!"); System.out.println(i++); System.out.println(++i); }} 猜猜运行结果,呵呵~
import javax.swing.JOptionPane; public class Test { public static void main(String[] args) { JOptionPane.showMessageDialog(null, "ok", "test", JOptionPane.PLAIN_MESSAGE); } } 图形界面的输出~
2.
3. public class SimpleFrameTest
4. {
5. public static void main(String[] args)
6. {
7. SimpleFrame frame = new SimpleFrame();
8. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
9. frame.setVisible(true);
10. }
11. }
12.
13. class SimpleFrame extends JFrame
14. {
15. public SimpleFrame()
16. {
17. setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
18. }
19.
20. public static final int DEFAULT_WIDTH = 300;
21. public static final int DEFAULT_HEIGHT = 200;
22. }
比如,我们要测一下jdk是否工作良好,可以写一个hello world
int i;
i=2;
System.out.println("hello!world!");
System.out.println(i++);
System.out.println(++i);
}}
猜猜运行结果,呵呵~
import javax.swing.JOptionPane;
public class Test
{
public static void main(String[] args)
{
JOptionPane.showMessageDialog(null, "ok", "test", JOptionPane.PLAIN_MESSAGE);
}
}
图形界面的输出~