Please keep in mind that this is a general question. I don't want to solve this problem only with arraylists, instead I want to know if there is a general solution for this. I know Arrays.asList(...) would do it here. The solution must also be applicable for existing classes without rewriting all setters to builder.
Sometimes I need a object only in a single line but in order to pass the objects' reference I need to declare a variable. I want to show you the following general example:
Person.addPhoneNumber((new ArrayList<String>()).add("0123456789").add("9876543210"));
This isn't working, because add() returns a boolean, so I lost my ArrayList reference.