是由这个问题https://segmentfault.com/q/1010000005725685引出的一个问题。
// Calendar.java
import java.text.DateFormatSymbols;
import java.util.*;
public class Calendar {
public static void main(String[] args) {
GregorianCalendar d = new GregorianCalendar();
}
}
用javac -Xlint Calendar.java
编译时并没有报warning,是否有什么选项让编译器报warning。
大家讲道理2017-04-18 09:16:53
There will be no warning, you are overthinking it, because of your Calendar
的命名空间(就是package
)肯定不是java.util
, right?
So, the compiler must identify conflicts based on "namespace + class name", so unless you do it package
也写成java.util
. Otherwise, I think it would be a bit overwhelming to have the compiler report an error/warning!
天蓬老师2017-04-18 09:16:53
I just learned Java this morning, and you guys confused me. I feel like I didn't expect it to be so complicated, I simply wrote the class name and file name wrong. It is normal that no warning is reported in this status. After all, the namespace of this class is different from the namespace of java calendar.