How to convert comma-separated String to List?

前端 未结 24 2317
你的背包
你的背包 2020-11-22 16:58

Is there any built-in method in Java which allows us to convert comma separated String to some container (e.g array, List or Vector)? Or do I need to write custom code for t

24条回答
  •  迷失自我
    2020-11-22 17:25

    Two steps:

    1. String [] items = commaSeparated.split("\\s*,\\s*");
    2. List container = Arrays.asList(items);

提交回复
热议问题