Tuesday, February 18, 2014

A one liner code to convert comma separated Strings to List in Java

No talking! Let's just do the code.

// String that is comma separated
String listOfUserIds = "10,11,12,13";

// The magic that converts it to list
List<String> userIds = new ArrayList<String>(Arrays.asList(listOfUserIds.split(",")));

Enjoy!

2 comments: