1 package com.Lucky.base;
2
3 public class dataType {
4 public static void main(String[] args) {
5 //数据类型 【 基本类型 和 引用类型 】
6 //拓展:==是比较值 ===是比较值和数据类型
7 //1.基本类型
8 //整数类型:byte[1字节 -128到127]
9 // short【2字节 -3万多到+3万多 】
10 // int 【4字节 -20亿到+20亿】
11 // long【8字节 19位数的长度】
12
13 //浮点数类型:float【4字节】
14 // double【8字节】
15
16 //布尔类型 :boolean
17
18 //字符类型:char【2字节】
19
20
21
22 //举例说明:
23 int num1=165656;
24 byte num2=127;
25 short num3=29999;
26 long num4=1656544856L;
27 float num5=1656.1F;
28 double num6=12.236674;
29 char name='A';
30 boolean res=false;
31 String name1="dbrhg";
32
33
34 System.out.printf(name1);
35
36
37 System.out.println("////**********///");
38 //整数拓展 八进制 十六进制
39 int q=10;
40 int w=010;
41 int e=0x10;
42 System.out.println(w);
43 System.out.println(q);
44 System.out.println(e);
45
46
47
48 System.out.println("////*****银行业务[BigDecimal]*****///");
49 //浮点数类型拓展:银行业务[BigDecimal]
50 float f=0.1f;
51 double test=(double) f;
52 System.out.println(test); //怎么转换都没有用
53 double d=1/(double)10;
54 System.out.println(d);
55 System.out.println(f==d); //false
56
57 float f1=25245535234f;
58 float d1=f1+1;
59 System.out.println(f1==d1); //true
60 ///避免使用浮点数类型 ;有限/大概/存在精度丢失问题
61
62
63 System.out.println("///////////////////////////////");
64 //字符拓展
65 char c1='A';
66 System.out.println(c1);
67 System.out.println((int) c1);//强行装换
68
69
70
71 //转义字符
72 // \t制表符
73 // \n换行
74 System.out.println("hoo\nhoo");//换行
75 System.out.println("hoo\thoo");//制表【空格】
76
77 String s1="123";
78 String s2="123";
79 System.out.println(s1==s2);
80
81
82 //对象之间不存在相等【引用类型】
83 String s3=new String("123");
84 String s4=new String("123");
85 System.out.println(s3==s4); //false
86
87
88 System.out.println("////////////////////////");
89 //boolean拓展
90 boolean b1=false;
91 if(b1){
92 System.out.println("Year");
93 }else{
94 System.out.println("No");
95 }
96 }
97 }