-2
I would call a method with parameter being an object of another class, but this object is created in a previous method?
Example:
Classea:
Public void cadastrar (Cliente cliente){
System.out.println (cliente.getNome());
}
Classeb:
Public void metodoDois (){
Cliente cliente = new Cliente();
}
ClasseA chamada = new classeA();
Chamada.cadastrar(cliente);
The method
metodoDoisthe way it is written is largely useless, except for an eventual side effect not clear that may arise at the instantiationcliente. Local variables (and arguments as well) can only be used within the scope of the function. Your example is not clear what you want.– Jefferson Quesado