Home >Java >javaTutorial >Implementation method of converting string to String array in Java

Implementation method of converting string to String array in Java

黄舟
黄舟Original
2017-10-13 09:58:263054browse

This article mainly introduces the method of converting string to String array in java, involving the traversal, segmentation, conversion and other related operation skills of java string. Friends in need can refer to the following

The examples of this article are described Java implements the method of converting string to String array. Share it with everyone for your reference, the details are as follows:


package Tsets;
import java.util.Arrays;
import java.util.List;
public class String2StringList {
 public static List<String> stringToList(String str){
  return Arrays.asList(str.split(","));
 }
 public static void main(String[] args) throws Exception {
  String str = "11111,21212,234234,23423424,234234";
  List<String> array = stringToList(str);
  for(String ss:array){
   System.out.println(ss);
  }
 }
}

Running results:

The above is the detailed content of Implementation method of converting string to String array in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn