power_settings_new

How to convert List<String> to List<Long>

by (262 points)
+1 vote
89 views
Having list of strings and want to convert into list of long. Please provide me some example.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes

At this point I can think of below as a solution for you.

List<Long> longList = new ArrayList<Long>();
longList.add(1L);
longList.add(2L);
 
List<String> stringList = new ArrayList<String>();
 
for(Long _long : longList)
stringList.add(String.valueOf(_long));
 
Hope that helps.
add
...