1 package cn.nxl2018;
2
3 public class Main_test {
4 public static void main(String args[]) {
5 System.out.println("应用程序入口的main方法");
6 main();
7 main(10);
8 main(10, 10);
9 }
10 public static void main(){
11 System.out.println("无参的main方法");
12 }
13 public static void main(int i){
14 System.out.println("有参的重载main方法");
15 }
16 public static void main(int i,int j){
17 System.out.println("有两个参数的重载main方法");
18 }
19 }
1 public class Main_test {
2 public static void main(String[] args) {
3 main2(args);
4 }
5 public static void main2(String[] args){
6 main(args);
7 }
8 }
3、main方法的继承
Main.java:
1 public class Main{
2 public static void main(String[] args) {
3 System.out.println("Hello Word!");
4 }
5 }
Main_test.java:
1 public class Main_test extends Main{
2 }
Main.java:
1 public class Main{
2 public static void main(String[] args) {
3 System.out.println("Main");
4 }
5 }
Main_test.java
1 public class Main_test extends Main{
2 public static void main(String[] args) {
3 System.out.println("Main_test");
4 }
5 }