截取字符串的问题
一段程序实现
把字符串的第二个单词取出。
(单词间间隔为空格)
请问如何实现啊
------解决方案--------------------class Split{
public static void main( String[] args ){
String[] s = "month week today hello ".split( " ");
System.out.println( s[1] );
}
}
------解决方案--------------------String s= "month week today hello ";
Scanner sc=new Scanner(s);
if(sc.hasNext())
{
sc.next();
if(sc.hasNext())
System.out.println(sc.next());
}