在千鋒“逆戰”學習第 3 天;
奮鬥沒有終點,任何時候都是一個起點;
今天學習的課程有4類8種基本數據類型,String引用數據類型,數據類型的自動以及強制轉換;
中國加油!武漢加油!千鋒加油!
我自己加油!
public class TestDateType{
public static void main(String[] args){
byte b = -128;
short s = 32767;
int i = 210000000;
long l1=100;
long l2 = 3000000000000L;
System.out.println(b);
System.out.println(s);
System.out.println(i);
System.out.println(l1);
System.out.println(l2);
System.out.println(Long.MAX_VALUE);
//此爲java內一種類的功能:long整型的最大取值
System.out.println("++++++++++++");
float f = 1.23F;
double d1 = 200;
//此隱含了int轉double型的自動轉換
double d2 = 2E2;
double d3 = 200.0;
//d1,d2,d3爲3個不同的表達方式。
System.out.println(f);
System.out.println(d1);
System.out.println(d2);
System.out.println(d3);
System.out.println("+++++++++++++");
boolean b1 = true;
boolean b2 = 3+2<4;
System.out.println(b1);
System.out.println(b1);
System.out.println("+++++++++++++");
char c1 = '中';
char c2 = 22269;
char c3 = '\u0041';
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
System.out.println("+++++++++++++");
String str = "武漢 加油";
System.out.println(str);
char c4 = '\'';
System.out.println("\'\\\"\tfright");
System.out.println(c4);
System.out.println("+++++++++++++");
byte bb1 = 2;
int ii1 = bb1;
System.out.println(ii1);
int ii2 = 128;
byte bb2 = (byte)ii2;
System.out.println(bb2);
/*
整型:2進制
byte--->short:自動轉換
byte:8位
0000 0001
short:16位
0000 0000 1000 0000
short-->byte:強制轉換,因爲數據存在不安全性
0000 0000 1000 0000
1000 0000
且整數都是以補碼存儲
*/
double dd1 = 1.23;
float ff1 = (float)dd1;
System.out.println(ff1);
float ff2 = 4.56F;
long ll1 = (long)ff2;
System.out.println(ll1);
char cc1 = 65;
int ii3 = cc1;
System.out.println(113);
short ss1 = -65;
char cc2 = (char)ss1;
System.out.println(cc2);
//(-65-->?)語法雖然正確,但是計算機卻找不到-65的編碼對應
}
}