Consider



Integer number = Integer.valueOf("808.1");

Which is true about the above statement?

A. The value of the variable number will be 808.1
B. The value of the variable number will be 808
C. The value of the variable number will be 0.
D. A NumberFormatException will be throw.
E. It will not compile.

題解

Integer為整數的Wrapper類別,若是想把不是整數的字串轉成Integer物件,會拋出NumberFormatException例外。