本帖最后由 周志伟 于 2013-5-29 22:59 编辑
- class Car
- {
- static String color = "pink";
- static int num = 10;
-
- public static void main(String[] args)
- {
- System.out.println("color = " + color + " ,num = " + num);
- }
- }
- class CeShi
- {
- static String name = "wesley";
- static int num = 10;
- public static void main(String[] args)
- {
- System.out.println("Hello World!");
- System.out.println("name = " + name + " ,num = " + num);
- }
- }
- class Car1
- {
- static String color = "pink";
- static int num = 10;
-
- public static void main(String[] args)
- {
- System.out.println("color = " + color + " ,num = " + num);
- }
- }
- class CeShi1
- {
- static String name = "wesley";
- static int num = 10;
- public static void main(String[] args)
- {
- System.out.println("Hello World!");
- System.out.println("name = " + name + " ,num = " + num);
- }
- }
复制代码 一个程序中一般有一个main函数,我的这个程序有4个main函数,也可以运行。运行结果见图。为什么啊?能讲解一下原理吗?谢谢啦。
|