String split by space using regular expression - Java Language Basics

Java examples for Language Basics:String

Description

String split by space using regular expression

Demo Code

public class Main {
  private String jaText = "this is a test ";


  public Main() {
    String[] fields = jaText.split("\\s", 3);
    for (String field : fields) {
      System.out.printf("Split: %s\n", field);
    }/*from   w ww. j  a  va2s.  co  m*/
  }
}

Related Tutorials