Java string和各種格式互轉 string轉int int轉string


Java string和各種格式互轉 string轉int int轉string

簡單收集記錄下

其他類型轉String

String s = String.valueOf( value); // 其中 value 為任意一種數字類型。 

字符串型轉換成各種數字類型:

String s = "169"; 


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 );


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM