java数字转字符串及字符串转数字
生活随笔
收集整理的這篇文章主要介紹了
java数字转字符串及字符串转数字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、使用integer類中的parseInteger方法
int intvalue= Integer.parseInteger(intString);例如:要將字符串“111”轉換成數字111
int a=Integer.parseInteger("111");//a=111其實很多數字類都支持從String轉換成 parse成數值:
byte b = Byte.parseByte("111"); short s = Short.parseShort("111"); int i = Integer.parseInt("111"); long l = Long.parseLong("111"); float f = Float.parseFloat("1.11"); double d = Double.parseDouble("1.11");2、數字轉化成字符串類型
各種數字類型轉換成字符串型:
字符串型轉換成各種數字類型:
String s = "122"; byte b = Byte.parseByte( s ); short t = Short.parseShort( s ); int i = Integer.parseInt( s ); long l = Long.parseLong( s ); Float f = Float.parseFloat( s ); Double d = Double.parseDouble( s );總結
以上是生活随笔為你收集整理的java数字转字符串及字符串转数字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: System.currentTimeMi
- 下一篇: javaGUI猜生日游戏