-4
I have 2 packages, I would like to import to package B all classes of package A.
-4
I have 2 packages, I would like to import to package B all classes of package A.
4
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 to a class.
To import all classes from package A to class B, you can do it two ways: explicit import or implicit import.
Explicit import is used when you import exactly that class of any package. For example:
import br.com.teste.controller.ClienteController;
Whereas ClienteController
is a class.
Implicit import is when you import all classes of some package into its 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. Only it can end up being a bit of a hassle depending on the package size.
To perform an implicit import do so:
import br.com.teste.controller.*;
Thus all the classes of the package br.com.teste.controller
shall be imported into their class.
Let’s assume that the package br.com.teste.controller
is composed of the 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.*;
Thank you for your reply c:
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Possible duplicate of Java - import all Static variables from another class
– Don't Panic
Hi Sabrina, it would be interesting if you detail your problem better. So it is easier to help you.
– viana