2009年2月19日 星期四

第170題

Given
:
12. String csv = "Sue,5,true,3";
13. Scanner scanner = new Scanner(csv);
14. scanner.useDelimiter(",");
15. int age = scanner.nextInt(),
What is the result?
A. Compilation fails.
B. After line 15, the value of age is 5.
C. After line 15, the value of age is 3.
D. An exception is thrown at runtime.
答案:D
參考:11-5 規則運算式與相關類別

-----------------------------------------

15行 nextInt() 碰到文字就會產生 InputMissmatchException.

沒有留言:

張貼留言