java代码中的问题

时间:2011-06-30 07:08:28

标签: java arraylist stringtokenizer

如何在java中向一个arraylist添加标记? 我想将标记添加到数组列表中。

StringTokenizer st = new StringTokenizer(line, ":Mode set - Out of Service In Service");
    while(st.hasMoreTokens()){
    out.println(st.nextToken());

1 个答案:

答案 0 :(得分:1)

List<String> list = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(line, ":Mode set - Out of Service In Service");
while(st.hasMoreTokens()){
  // out.println(st.nextToken());
  list.add(st.nextToken());
}