2017-02-14 Head First Java 第一章 下
1:Java數組的聲明
String[] pets = {“Fido”,”Zeus”,”Bin”};
2:查詢數組的長度
int x = pets.length;
3:獲取0-1的隨機數
調用這個Math.Random()函數能夠返回帶正號的double值,該值大於等於0.0且小於1.0,即取值範圍是[0.0,1.0)的左閉右開區間,返回值是一個僞隨機選擇的數,在該範圍內(近似)均勻分佈。
4:強制類型轉換
int x = (int)24.6;
5:連接字符串
s = s + “ “ + “is a dog”; // “Fido is a dog”
6:提取數組元素
String = pets[0]; // “Fido”
7:Java是一個強類型的語言,着代表Java編譯器不允許變量保存類型的數據。這是很關鍵的類型安全性功能。
1. Not an integer (or _____ your boat):float vt 浮動、漂浮
2. Come back empty-handed:void/come back empty-handed 空手而歸/And we both know he'll come back empty-handed.
5. ‘Things’ holders:arrays/holder n 持有者,持有物
7. Until attitudes improve:while/improve [ɪmˈpruv] v 提高、利用、改善、改良
8. Can’t go both ways:branch
10. Source code consumer:compiler/consumer [kənˈsu:mə(r)] n 消費者、顧客
11. Can’t pin it down:variable
12. number variable type:int/pin [pɪn] n 針、別針 v 釘住,扣住
13. Acronym for a chip:IC/acronym ['ækrənɪm] n 首字母縮寫/chip [tʃɪp] n 碎片、芯片
16. Just gotta have one:main/Just gotta have one 只要有一個/gotta [ˈgɑ:tə] v 必須
18. Quite a crew of characters:string/quite [kwaɪt] adv 相當、非常、確實如此/crew [kru] n 一羣、一幫
19. Announce a new class or method:declare/announce [əˈnaʊns] v 宣佈、聲稱/declare [dɪˈkler] v 宣佈、聲明
20. Bytecode consumer:JVM/bytecode [bɪti:'koʊd] n 字節碼/JVM Java Virtual Machine