I have 2 packages, I would like to import package B into all classes of package A.
I have 2 packages, I would like to import package B into all classes of package A.
I would like to import into package B all classes of package A
It is impossible to import classes into another package. This does not exist.
It is only possible to import classes from a package into a class.
To import all classes from package A to class B, you can do two ways: explicit import or import implicit .
Explicit import is used when you import exactly that class from some package. For example:
import br.com.teste.controller.ClienteController;
Being ClienteController
is a class.
Implicit import is when you import all the classes of some package into your class without declaring the import one by one.
Understand: You can import all classes of a package into your class using explicit import as well. It may just be a little painful depending on the size of the package.
To perform an implicit import, do the following:
import br.com.teste.controller.*;
In this way all the br.com.teste.controller
package classes will be imported into your class.
Let's assume that the br.com.teste.controller
package is made up of classes:
ClienteController
UsuarioController
ProdutoController
PedidoController
Explicit Import :
import br.com.teste.controller.ClienteController;
import br.com.teste.controller.UsuarioController;
import br.com.teste.controller.ProdutoController;
import br.com.teste.controller.PedidoController;
Implicit import :
import br.com.teste.controller.*;