(1) 字符串string轉int:
int i=Integer.parseInt(str);//使用Integer.parseInt(String str)函數,返回str所代表的int值;
(2) 如何將字串 String 轉換成Integer
Integer integer=Integer.valueOf(str);//string轉Integer對象
(3) 將整數 int 轉換成字串 String
1.) String s = String.valueOf(i);//使用String.valueOf(int i);返回String
2.) String s = Integer.toString(i); //使用Integer.toString()
3.) String s = “” + i; //比較low的一種方式
(4) 將整數 int 轉換成Integer
Integer integer=new Integer(i);
(5) 將Integer 轉換成字串 String
Integer integer=String
(6) 將Integer 轉換成 int
int num=Integer.intValue();
(7) 將String轉換成 BigDecimal
BigDecimal d_id = new BigDecimal(str);
(8) 將 String 轉換成 char
char[] ca=”123”.toCharArray();
(9) 將char轉換成String
String s=ca.toString(); //任何類型都可以採用toString()轉換成String類型