How to convert a String into an ArrayList?

前端 未结 13 606
囚心锁ツ
囚心锁ツ 2020-11-28 04:32

In my String, I can have an arbitrary number of words which are comma separated. I wanted each word added into an ArrayList. E.g.:

String s = \"a,b,c,d,e,...         


        
相关标签:
13条回答
  • 2020-11-28 05:06

    If you're using guava (and you should be, see effective java item #15):

    ImmutableList<String> list = ImmutableList.copyOf(s.split(","));
    
    0 讨论(0)
提交回复
热议问题