題目:
| 描述 | |
|---|---|
| 知識點 | 字符串,循環 | 
| 運行時間限制 | 0M | 
| 內存限制 | 0 | 
| 輸入 | 一行字符串,長度小于128。  | 
| 輸出 | 整數N,最后一個單詞的長度。  | 
| 樣例輸入 | hello world | 
| 樣例輸出 | 5 | 
The java.util.Scanner.hasNext():This method Returns true if this scanner has another token in its input. This method may block while waiting for input to scan. The scanner does not advance past any input
StringcharAt() Method:This method returns the character located at the String's specified index. The indexes start from zero.
java.util.Scanner.Next():This method returns a String object which is a complete token of the Scanner object.
Example:
public class Test {   public static void main(String args[]) {      String s = "Strings are immutable";      char result = s.charAt(8);      System.out.PRintln(result);   }}Result:a
新聞熱點
疑難解答