I am trying to compile following piece of code:
public class DuplicateMainExample {
public static void main(String[] args) {
System.out.print("A1");
}
public static void main(String... args) {
System.out.print("A2");
}
}
In Eclipse it's working fine, but with warnings on the both methods - "Duplicate method main(String[]) in type DuplicateMainExample"
Using javac
(java version "1.7.0_09") I have an compilation error:
>javac DuplicateMainExample.java
DuplicateMainExample.java:8: error: cannot declare both main(String...) and main
(String[]) in DuplicateMainExample
public static void main(String... args) {
^
1 error
How to compile in Eclipse using javac
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…