package study;
public class exercise {
public static void main(String[] args) {
//其他类型转换成字符串
int a=1234;
float b=(float) 1.234;
double c=12.34;
long d=12345;
char e='1';
byte f=123;
boolean g=false;
//转换的方法:格式: String.valueOf(变量);
String str;
str = String.valueOf(a);
System.out.println(str);
str = String.valueOf(b);
System.out.println(str);
str = String.valueOf(c);
System.out.println(str);
str = String.valueOf(d);
System.out.println(str);
str = String.valueOf(e);
System.out.println(str);
str = String.valueOf(f);
System.out.println(str);
str = String.valueOf(g);
System.out.println(str);
}
}
16.5其它数据类型转换为字符串
最新推荐文章于 2021-05-21 18:00:59 发布