标签:
package javase; public class Demo0422 { public static void main(String[] args) { // TODO Auto-generated method stub //char 2位 , byte 字节 , short 2字节 , int float 4字节 ,double long 8字节 //引用数据类型:数组,类,接口。默认值为null //字符数据类型 char ch1 = ‘a‘; char ch2 = 97; System.out.println(ch1); System.out.println(ch2); System.out.println(‘\\‘); System.out.println(‘\"‘); System.out.println(‘\n‘+"\n\"hello world\""); //浮点数类型 float f = 3.1f;//默认是double类型,float就够了 System.out.println(f*f); //布尔型 boolean b = true;//默认是false System.out.println(b); //数据类型转换 int x = (int)30.3f;//强制转换 float y = 22.19f; System.out.println(x/y); System.out.println(10/3.5); System.out.println(10/3); String s = "lirui "; s = s + x; System.out.println(s);//任何类型数据都向String转型 System.out.println("lirui " + x + 88);//任何类型数据都向String转型 System.out.println((0.1+0.1+0.1) == 0.3); System.out.println(1.0 - 0.1); System.out.println(1.0 - 0.2); System.out.println(1.0 - 0.3); System.out.println(1.0 - 0.4); System.out.println(1.0 - 0.5); System.out.println(1.0 - 0.6); System.out.println(1.0 - 0.7); System.out.println(1.0 - 0.8); System.out.println(1.0 - 0.9); System.out.println(1.0 - 1.0); } }
标签:
原文地址:http://www.cnblogs.com/lvxiaorui/p/4648608.html