Java - Creating a method that will set values on a object, return the object or set using the passed param? : I am creating a method in my Java project which simply set values of an object. Common approaches are returning the object being set and the other one is setting the object which was passed in the parameter. Can you give me advantages and disadvantages of both scenario(even its memory consumption or performance or even the minor differences or when to use them), both works but maybe there are key points that I missed. Thanks!

Return the object being set.

    public Car setCarDetails(){
        Car car = new Car();
        car.setName("Tesla Model S");
        car.setBrand("Tesla");
        car.setPrice(45000);
        return car;
    }

Set using the object passed in the parameter

    public void setCarDetails(Car car){
        car.setName("Tesla Model S");
        car.setBrand("Tesla");
        car.setPrice(45000);
    }

