I have a question, what is the difference between these 2 ways of storing an object? In this first form I create an object and assign it to another one that is the result of a search in the database:
User user = new User(); user = userService.findById(idUser);
and this other way:
User user = userService.findById(idUser);
is about what is POO and what is instantiate and all that, but I do not understand what would be the difference between creating an object and assigning a value to reference an object (as a type) and assign a value, to my second opinion would be the best option but I do not know if I am correct, if someone could explain it to me I would appreciate it. Thanks.