Java Class and Interface Name Collision
问题 interface A { void print(); } class A implements A { public void print() { System.out.println("Hello"); } public static void main(String args[]) { A a=new A(); a.print(); } } When i am using this code then it is saying "duplicate class:A". Why so? Can I not have same class and interface name 回答1: You can't have a class and an interface with the same name because the Java language doesn't allow it. First of all, it's ambiguous. If you declare a variable like this: A a; What is the type of that