Home > Java > javaTutorial > body text

Implementation method of converting string to String array in Java

黄舟
Release: 2017-10-13 09:58:26
Original
3015 people have browsed it

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);
  }
 }
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template