Teach Yourself Java 2 in 21 Days 书中样例代码实践
生活随笔
收集整理的這篇文章主要介紹了
Teach Yourself Java 2 in 21 Days 书中样例代码实践
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
找了好幾書JAVA的書,看了幾章,都看不下去。
我覺得適合《Teach Yourself Java 2 in 21 Days》(Rogers Cadenhead Laura Lemay)還是適合我的。
孫衛(wèi)琴那本,我感覺就羅嗦多了沒到我點(diǎn)子上。
接口,抽象類這些內(nèi)容講得通俗易懂,看著不費(fèi)力。
代碼:
1 class VolcanoRobot { 2 String status; 3 int speed; 4 float temperature; 5 6 void checkTemperature() { 7 if (temperature > 660) { 8 status = "returning home."; 9 speed = 5; 10 } 11 } 12 13 void showAttributes() { 14 System.out.println("Status: " + status); 15 System.out.println("Speed: " + speed); 16 System.out.println("Temperature: " + temperature); 17 } 18 }?
1 class VolcanoApplication { 2 public static void main(String[] arguments) { 3 VolcanoRobot dante = new VolcanoRobot(); 4 dante.status = "exploring"; 5 dante.speed = 2; 6 dante.temperature = 510; 7 8 dante.showAttributes(); 9 System.out.println("Increasing speed to 3."); 10 dante.speed = 3; 11 dante.showAttributes(); 12 System.out.println("Changing temperature to 670."); 13 dante.temperature = 670; 14 dante.showAttributes(); 15 System.out.println("Checking the temperature."); 16 dante.checkTemperature(); 17 dante.showAttributes(); 18 } 19 }?
運(yùn)行:
?
轉(zhuǎn)載于:https://www.cnblogs.com/aguncn/archive/2013/03/28/2986637.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的Teach Yourself Java 2 in 21 Days 书中样例代码实践的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IIS 崩溃的后的感受
- 下一篇: Java学习心得——对象与类