當(dāng)前位置:
首頁(yè) >
String 和Integer、int之间互转
發(fā)布時(shí)間:2025/5/22
46
豆豆
生活随笔
收集整理的這篇文章主要介紹了
String 和Integer、int之间互转
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
String轉(zhuǎn)Integer
String str = "10"; Integer it = Integer.valueOf(str);Integer轉(zhuǎn)String
Integer it = new Integer(10); String str = it.toString();int 轉(zhuǎn)Integer
int i = 10; Integer it = new Integer(i);Integer轉(zhuǎn)int
Integer i = new Integer(10); int k = i.intValue();int轉(zhuǎn)String
1、String s = String.valueOf(i);
2、String s = Integer.toString(i);
3、String s = “” + i;//會(huì)產(chǎn)生兩個(gè)string對(duì)象
String轉(zhuǎn)int
1、int i = Integer.parseInt(String);
2、i=Integer.valueOf(s).intValue();//Integer.valueOf(s) \相當(dāng)于 new Integer(Integer.parseInt(s)),也會(huì)拋異常,但會(huì)多產(chǎn)生一個(gè)對(duì)象
?
轉(zhuǎn)載于:https://www.cnblogs.com/jiaorenzhan/p/10623943.html
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的String 和Integer、int之间互转的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux基础第四课——文件操作
- 下一篇: 《校园地图》的剖析