集册 Java实例教程 使用\\ s +将字符串分解为单独的单词

使用\\ s +将字符串分解为单独的单词

欢马劈雪     最近更新时间:2020-01-02 10:19:05

459
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用\\ s +将字符串分解为单独的单词

public class CountWords

{

/** 
来 自 
时代Java公众号 - nowjava.com
**/

  public static void main(String[] args)

  {

    String s = "this is a test 1 2 3 4.";


    String[] word = s.split("\\s+");


    for (String w : word)

      System.out.println(w);


  }

}