For example I have A.java. in A.java I have:
public class A {
// normal
}
class B { // cannot declare: public class B
}
And in same package with A.java. I create C.java and declare:
public class C {
public void methodC() {
A a = new A();
B b = new B(); // no error -> B is a public class
}
}
If I create new class B in file C.java. C will refer class B in file C.java, not A.java.
class B {
}
public class C {
public void methodC() {
B b = new B(); //this B refer to C.java rather than A.java
}
}
So, I have seen some problem here: in same package, there will be two same class. So, when I create D.java, how can I know which class B will be refered to ?
And another question, what real type of class B, when I declare it outside of class A and class C. This point makes me feel frustrated so much.
Thanks 🙂
When You had already done this in
A.java:You won’t be able to define
class Bin sameC.javain same package as it already exists in same packageWhat I have tried is below and it showed me this: