"SCJP 1.6版考題 177" 修訂間的差異
出自 陳富國維基館
(新頁面: Given: 11. String test = "This is a test"; 12. String[] tokens = test.split(“\s"); 13. System.out.println(tokens.length); What is the result? A. 0 B. 1 C. 4 D. Compila...) |
(無差異)
|
於 2013年3月30日 (六) 01:56 的最新修訂
Given: 11. String test = "This is a test"; 12. String[] tokens = test.split(“\s"); 13. System.out.println(tokens.length); What is the result? A. 0 B. 1 C. 4 D. Compilation fails. E. An exception is thrown at runtime.
解答
Ans: D
解說:
\s倒斜線是表示逸出字元,在C/Java裏沒有定義\s這個逸出字元,程式改成: class test{ public static void main(String[] args) { String test = "This is a test"; String[] tokens = test.split(" "); System.out.println(tokens.length); } }
|