+ 1
How can we access a public class that is inside a package1 from another package2 and this package2 is inside that package1
In java using the command prompt I created a package1 and inside it I created another folder package2 then created a class A in package1 then I go to package2 and create a public class B and creat object A a= newA(); When i compile file B.java i get an error: cannot find symbol A Where is the mistake I try import package1.A in B.java file but the same error keeps appearing What should I keep in mind?
3 Antworten
+ 2
Martin Taylor
What if i put inside file B the following
package foo.bar;
import foo.A;
public class B{
public static void main (String[] args ){
A a= new A();
}
}
Knowing that there is no other classes have the same name as A and B
why it generate error??