SCJP 1.6版考題 159
出自 陳富國維基館
Given: 11. double input = 314159.26; 12. NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN); 13. String b; 14. //insert code here Which code, inserted at line 14, sets the value of b to 314.159,26? A. b = nf.parse(input); B. b = nf.format(input); C. b = nf.equals(input); D. b = nf.parseObject(input);
解答
Ans: B
解說:
14行插入那一行設定了b物件的值為314.159,26 parse(剖析)的語意一般是從字串轉成所要的類別型態物件,如Integer.parseInt NumberFormat中的format方法是將數值以所指定的格式輸出,回傳值型態是String
|