8種基本數(shù)據(jù)類型有相應(yīng)的8種包裝類(Wrapper)對(duì)應(yīng),分別是:Character,Byte,Short,Integer,Long,Float,Double,Boolean. 特點(diǎn): 1.提供了valueOf(String)用于從字符串轉(zhuǎn)換及toString()轉(zhuǎn)換成字符串 2.通過xxxxValue()方法可以得到所包裝的值,如Integer對(duì)象的intValue()方法. 示例代碼: public class DoubleAndString { public static void main(String[] args) { System.out.println("===change String to double==="); System.out.println("d is " + d); //Returns a new double initialized to the value represented } } |
|
來(lái)自: dabinglibrary > 《java》