Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners import package.subpackage.* does not work
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jaga
import package.subpackage.* does not work
0 Answer(s)      3 years and a month ago
Posted in : Java Beginners


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.


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com