Conversion between Java string and various formats

Convert other types to String:

String s = String.valueOf( value); // 其中 value 为任意一种数字类型。 

The string type is converted into various numeric types:

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

Guess you like

Origin blog.csdn.net/qq_43229056/article/details/109142297