I always had the doubt between whether it is better to create a object
and then use a method of that object or not to create the object, examples:
- Without having created an object of the class that would return
otroMetodo()
:
Sistema.algunMetodo().otroMetodo().print(algo, "Hola");
Sistema.algunMetodo().otroMetodo().print(algo, "¿Cómo");
Sistema.algunMetodo().otroMetodo().print(algo, "Estás?");
- With an object:
ClassDeOtroMetodo claseDeOtroMetodo = Sistema.algunMetodo().otroMetodo();
claseDeOtroMetodo.print(algo, "Hola");
claseDeOtroMetodo.print(algo, "¿Cómo");
claseDeOtroMetodo.print(algo, "Estás?");
Is there a big difference or is it the same?