public class MyString//将primitive主数据类型换为String
{
public static void main(String [] args)
{
double d=42.5;
String doubleString=""+d;
System.out.println(doubleString);
String doubleString2=Double.toString(d);
System.out.println(doubleString2);
}
}
public class Transport//将String换为主数据类型
{
public static void main(String [] args)
{
String s="2";
int x=Integer.parseInt(s);
double d=Double.parseDouble("420.4");
boolean b=new Boolean("true").booleanValue();
System.out.print(x+" "+d+" "+b);
String t="two";
int y=Integer.parseInt(t);
}
}
String 与primitive主数据类型的转换
最新推荐文章于 2020-04-03 16:28:27 发布