Common types in java and common types in java
1. Convert the String to an integer (String ---> int)
Method 1:
(1) int I = Integer. parseInt (String s );
Among them, (1) is actually the number we often use to convert s to a 10-digit number. In fact, the default is to call int I = Integer. parseInt ("123", 10 );
(2) I = Integer. parseInt (String s, int radix );
The range of radix is 2 ~ If the value range is greater than 36, an exception is thrown. The length of s cannot exceed 7. Otherwise, an exception is thrown.
Method 2:
Int I = Integer. valueOf (my_str). intValue ();
Note: The methods for converting a string to Double, Float, and Long are similar to those above.
2. How to convert an integer to a String (int ---> String)
(1) String s = String. valueOf (I );
(2) String s = Integer. toString (I );
(3) String s = "" + I;
Note: Convert Double, Float, and Long into stringsSimilar to the above.