Answers for "convert object to list"

5

how to convert object to list in java

//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.
Posted by: Guest on October-06-2021
0

convert object to list of objects c#

IList collection = (IList)myObject;
Posted by: Guest on April-04-2020

Code answers related to "convert object to list"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language