I was wondering if one can get a List
from an object, add an item to it, and set the List
to the object in one line.
I would normally do it this way:
List<String> tempList = someObject.getList();
tempList.add("some string value");
someObject.setList(tempList);
What I tried doing was this:
someObject.setList(someObject.getList().add("some string value"));
But then I realized that the method add()
would return a boolean while the method setList()
takes a List<String>
Any ideas?