I have 3 class files. A.java B.java C.java Below is the code block
A.java:- package com.test; public class A { public void funA() { System.out.println("funA"); } } B.java:- package com.test; public class B { public void funB() { System.out.println("funA"); } } C.java:- import com.test.*; class C { public static void main(String[] args) { A a = new A(); B b = new B(); } }
When i am compiling the above 3 class, i am getting an error message like
.\A.java:2: duplicate class: com.test.A public class A ^ C.java:6: cannot access A bad class file: .\A.java file does not contain class A Please remove or make sure it appears in the correct subdirectory of the classpath. A a = new A(); ^ 2 errors
But when instead of import com.test.* i write import com.test.A; it works. kindly explain me. I am a new user to this site.
Ads