import package.subpackage.* does not work

import package.subpackage.* does not work

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.

View Answers









Related Tutorials/Questions & Answers:
import package.subpackage.* does not work
Jquery form validation does not work
Advertisements
Jquery form validation does not work
How does the Java for each loop work?
ModuleNotFoundError: No module named 'does-this-even-work-anymore'
What is data analysis, and how does it work?
How many hours does a data scientist work?
How does Hadoop distributed file system work?
Insert option does not work in my jstl... - JDBC
In netbean jdk, it does not import the file,"java.nio.file.Paths". why?.
How does Social Media Marketing Work
How many hours a week does a data scientist work?
How does this example work even if no oracle to be used and only access is available?
Does importing a package imports the subpackages as well? e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests?
where are the all library files of netbeans 7.0 ? Because it does not import the file,"java.nio.file.Paths"
validator framework work in Struts
Message Resource Bundle work.
How does LBS work?
validate() method of ActionForm work
sing validator framework work in struts
How Does the Display Work for the iPad?
jvm work
package org.hibernate.util does not exist
Does hibernate support polymorphism?
package javax.ws.rs does not exist
Does memory for Class or Object?
package javax.servlet does not exist
What is a Proxy Server, and How Does it Work?
What does COMMIT do?
package javax.validation does not exist
ModuleNotFoundError: No module named 'Work'
Does Google use R?
Does SPSS use Python?
Does true AI exist?
Does AI require coding?
Does Google use AI?
Does ml require coding?
Does Coding increase IQ?
Does Python require math?
how formBackingObject() method will work.
collection frame work
package org.springframework.scheduling.quartz does not exist
What does the delete operator do?
What does the delete operator do?
Does finally always execute in Java?
work - JSP-Servlet
collection frame work
collection frame work
import file
How to work with Ajax in spring

Ads