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);
}
}
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。