import java.math.BigDecimal;
public class helloworld {
public static void main(String[] args) {
double d=.00001005; // .前面的0可以省略
float pi=3.1415926f; //后缀必须有f/F.float表示的数不精确 打印出来是float pi=3.1415925
int l=20_000; //下划线是分隔符,增加可读性
BigDecimal b=new BigDecimal("3.1415926"); //可以精确的打印,bigdecimal b=3.1415926
System.out.println("double d="+d);
System.out.println("float pi="+pi);
System.out.println(Float.SIZE); //表示float类型,多少个二进制位
System.out.println("bigdecimal b="+b);
}
}
运行结果:
double d=1.005E-5
float pi=3.1415925
32
bigdecimal b=3.14159
public class charbooldemof {
public static void main(String[] args) {
boolean b;
char ch1,ch2;
ch1='Y';
ch2=65;
System.out.println("ch1="+ch1+",ch2="+ch2);//ch1=Y,ch2=A
b=ch1==ch2;
System.out.println(b);//false
ch2++;
System.out.println("ch2="+ch2);//ch2=B
}
}