So public variables can be accessed from anywhere, even from other packages. However, when I try to create an object from a foreign package, in order to get access to the public variables it contains, I get the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Foo cannot be resolved to a type
My code:
Foo obj = new Foo();
I was wondering what is the correct way to create objects that exist in packages other than the one thats creating it?
I appreciate any help in this regard.
Did you
import Foo;?with qualified name
com.some.package.FooIf you declare your class
FooThen you need to import this type by writing
in any other(other than
com.some.package) package whereFoois usedSee