import package.subpackage.* does not work

Ads
 

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

Ads









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 does Hadoop distributed file system work?
In netbean jdk, it does not import the file,"java.nio.file.Paths". why?.
How does Social Media Marketing Work
How does this example work even if no oracle to be used and only access is available?
where are the all library files of netbeans 7.0 ? Because it does not import the file,"java.nio.file.Paths"
package org.hibernate.util does not exist
How Does the Display Work for the iPad?
Does hibernate support polymorphism?
package javax.ws.rs does not exist
Does memory for Class or Object?
package javax.servlet does not exist
package javax.validation does not exist
Does finally always execute in Java?
ModuleNotFoundError: No module named 'Work'
package org.springframework.scheduling.quartz does not exist
collection frame work
collection frame work
collection frame work
Does finally always execute in Java?
Does finally always execute in Java?
Does finally always execute in Java?
What does core Java include?
Does Java support multiple inheritance?
Does Java support multiple Inheritance?
Does Java support multiple Inheritance?

Ads