Question : how to convert object to list in java
Answered by : dwij-sheth
//Assuming that your object is a valid List object, you can use: Collections.singletonList(object) -- Returns an immutable list containing only the specified object.
List<Object> list = Collections.singletonList(object);
//If you want it in a specific datatype, use Stream.of(object):
List<String> list = Stream.of(object).map(Object::toString).collect(Collectors.toList())
//Similarly, you can change the method in the map to convert to the datatype you need.
Source : | Last Update : Wed, 13 Oct 21
Question : java object into list
Answered by : homely-hare-2pth835yi741
return Arrays.asList(Object);
Source : https://stackoverflow.com/questions/20358883/how-to-quickly-and-conveniently-create-a-one-element-arraylist | Last Update : Thu, 14 Apr 22