1.编码格式转换
try{
mytext= java.net.URLEncoder.encode(search,"utf-8");
}catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
2.String类型转换为int类型
String str = "123";
try {
int a = Integer.parseInt(str);
} catch (NumberFormatException e) {
e.printStackTrace();
}
=============================
String str = "123";
try {
int b = Integer.valueOf(str).intValue()
} catch (NumberFormatException e) {
e.printStackTrace();
}
3.Int类型转换为String
String s = String.valueOf(i);
String s = Integer.toString(i);
String s = "" + i;
类型的几种转换
最新推荐文章于 2022-01-06 00:18:52 发布