标签:parse get float val 利用 必须 color ati stat
public class changetype { public static void main(String[] args) { String ar = "true"; //String转 boolean ,只要不是"true",结果即为false; boolean ar1 = Boolean.parseBoolean(ar); if(ar1) { System.out.println("true"); //结果为true; } String str = "12"; //String 转 int int m = Integer.parseInt(str); System.out.println(m); String str0 = "12.6"; //string转换成double double x = Double.parseDouble(str0); System.out.println(x); int y = 5; String str1 = y+""; System.out.println(str1); int flag = 100; //int转String,任何类型与字符串连接将变为字符串类型。不推荐使用 String a = flag+""; System.out.println(a); int flag0 = 200; //int 转String 利用String.valueOf(); String str3 = String.valueOf(flag0); System.out.println(str3); float h = 12.6f; // float 转 int ,由高到低必须进行强制类型转换,损失精度变为12 int w =(int)h; System.out.println(w); //结果为12 float c = 89.6666f; double s = c; System.out.println(s); //结果为89.666677987979 double e = 78.999999999; float o = (float)e; System.out.println(o); //结果为79 }}
标签:parse get float val 利用 必须 color ati stat
原文地址:http://www.cnblogs.com/2206411193qzb/p/7479954.html