Java – Split a String into an Array

The following example convert a comma separated string into an array.

public class StringToArrayDemo {
  public static void main(String[] args) {
    String s = "ykyuen,wordpress,com";
    String[] values = data.split(",");
    for (String value:values) {
      System.out.println(value);
    }
  }
}

 

Done =)

Reference: Kodejava – How do I split a string?

4 thoughts on “Java – Split a String into an Array”

Leave a reply to ykyuen Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.