public class test {
public static void main(String[] args) throws Exception {
// int---->String
int a = 10;
String str = a + "";
String str1 = String.valueOf(a);
String str2 = Integer.toString(a);
System.out.println(str + " " + str1 + " " + str2);
// String---->int
String s = "123";
int b = Integer.parseInt(s);
int c = Integer.valueOf(s);
System.out.println(b);
// Stirng---->char[]
String str3 = "abc";
char[] ch = new char[str3.length()];
for (int i = 0; i < str3.length(); i++) {
ch[i] = str3.charAt(i);
}
}
}
java数据类型转化
猜你喜欢
转载自blog.csdn.net/progammer10086/article/details/81186417
今日推荐
周排行