Teach Yourself Java 2 in 21 Days 书中样例代码实践

找了好几书JAVA的书,看了几章,都看不下去。

我觉得适合《Teach Yourself Java 2 in 21 Days》(Rogers Cadenhead Laura Lemay)还是适合我的。

孙卫琴那本,我感觉就罗嗦多了没到我点子上。

接口,抽象类这些内容讲得通俗易懂,看着不费力。

代码:

 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 }

 

运行:

 

转载于:https://www.cnblogs.com/aguncn/archive/2013/03/28/2986637.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/274307.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

黑书上的DP例题

pagesectionnotitlesubmit1131.5.1例题1括号序列POJ11411161.5.1例题2棋盘分割POJ11911171.5.1例题3决斗Sicily18221171.5.1例题4“舞蹈家”怀特先生ACM-ICPC Live Archive1191.5.1例题5积木游戏http://202.120.80.191/problem.php?problemid12441231.5.2例题1方块消除http://…

MDK linker和debug的设置以及在RAM中调试

有误或者表述不清楚请指出,谢谢 硬件:TQ2440开发板、jlink V8 固件 软件:J-LINK ARM 4.08i、MDK4.20 先解释下MDK中三种linker之间的区别 设置集中在option linker选项卡 1.采用Target对话框中的ram和rom地址。采用此方式,…

LBS核心技术解析(引子)

http://www.cnblogs.com/LBSer/archive/2013/04/25/3048754.html 引子: 人们常用“上知天文,下知地理”来形容一个人的博学,人们总是用三要素论“什么时间、什么地点,发生或干了什么事情”来描述一件事情,人们也常常借用“天时、地…

Vim中数字自增、自减

(1)ctrl a:数字自动增加1 按下ctrl a: (2)number ctrl a:数字自动增加number 例子:想将20修改成100,按下80 ctrl a: (3)ctrl x…

开源服务器Tornado的初步了解

文章结束给大家来个程序员笑话:[M] 明天看了下Python的一个新web框架,由Facebook开源。不得不说,品牌效应啊,只要是Facebook开源的目项,没有不好用的。Tornado可以说是好用到了极致,从开打官方面页开始懂得…

多线程的那群“象”

最初学习多线程的时候,只学了用Thread这个类,记忆中也用过Mutex,到后来只记得Thread的使用,其余的都忘了。知道前不久写那个Socket连接池时遇到了一些对象如:Semaphore,Interlocked,Mutex等&…

优秀HTML5网站学习范例:从“饥饿游戏浏览器”谈用户体验

继影片《饥饿游戏》获得票房成功后,《饥饿游戏2:火星燎原》也于2012年宣布开拍,将在今年的11月22日登陆全球各大院线。值此之际,微软携手美国狮门影业公司和 RED Interactive Agency 一起为影迷打造了一个基于 HTML5 现代网页规范…

[开源]jquery.ellipsis根据宽度(不是字数)进行内容截断,支持多行内容

jquery.ellipsis 自动计算内容宽度(不是字数)截断,并加上省略号,内容不受中英文或符号限制。 如果根据字数来计算的话,因为不同字符的宽度并不相同,比如l和W,特别是中英文,最终内容宽…

不安装游戏apk直接启动法

原文地址:http://blog.zhourunsheng.com/2011/09/%E6%8E%A2%E7%A7%98%E8%85%BE%E8%AE%AFandroid%E6%89%8B%E6%9C%BA%E6%B8%B8%E6%88%8F%E5%B9%B3%E5%8F%B0%E4%B9%8B%E4%B8%8D%E5%AE%89%E8%A3%85%E6%B8%B8%E6%88%8Fapk%E7%9B%B4%E6%8E%A5%E5%90%AF%E5%8A%A8%E6%B3%95…

Android客户端打包方案分享

基本介绍 Android应用的自动化打包是应用持续集成以及多渠道发布的基础。当前Android客户端自动化打包的主要有两种方式,Ant和Maven。两种方式本质上都是调用Android SDK里面提供的工具,不过各自有各自的特点。 1. Ant脚本 好处:开发成本较低…

您的UX库不只是书籍

hp ux 密码不过期Looking back on past self, one thing I wish I’d realised is the importance of keeping notes of everything.回顾过去的自我,我希望我意识到的一件事是记录所有事情的重要性。 This means everything interesting I’ve read and written; e…

交互设计精髓_设计空间的精髓

交互设计精髓重点 (Top highlight)什么是空间? (What is Space?) Space is the dimension of height, depth and width within which all things exist and move. Space or Empty space or White space or Negative space are alias given to describe intensional…

ux和ui_UI和UX设计人员的47个关键课程

ux和ui重点 (Top highlight)This is a mega-list of the most critical knowledge for UI, UX, interaction, or product designers at any level.这是所有级别的UI,UX,交互或产品设计人员最关键的知识的大清单。 Many of these lessons are also appli…

深入理解Java内存模型(七)——总结

处理器内存模型 顺序一致性内存模型是一个理论参考模型,JMM和处理器内存模型在设计时通常会把顺序一致性内存模型作为参照。JMM和处理器内存模型在设计时会对顺序一致性模型做一些放松,因为如果完全按照顺序一致性模型来实现处理器和JMM,那么…

沉浸式ui设计_有助于沉浸的视频游戏UI —武器轮

沉浸式ui设计Many action-adventure games rely on the feeling of thrills via bullets, fire, grenade, more bullets, and gigantic booms. The way to enable all these is to offer a massive arsenal, from machetes to assault rifles all the way till bazookas.许多动…

ux设计师薪水_客户现在也是UX设计师

ux设计师薪水Some of you probably know by now, I’m not too fond of the monster the UX industry has become. It’s overblown, overcomplicated and often dishonest towards the clients. It’s also in itself undefined. (where is the E in Experience?)你们中的某些…

分步表单_角色创建分步指南

分步表单The first thing most of us designers are taught is the concept of personas and the necessity of them when it comes to UX and product design. However, knowing is different from applying and it can be difficult to know where to begin when we’re aske…

svg配合css3动画_带有Adobe Illustrator,HTML和CSS的任何网站的SVG动画

svg配合css3动画A top trend in web design for 2020 is the increased use of SVG animations on web pages and in logo design. In this article, we will implement a simple and straight forward method to create relatively complex animation. We will use Adobe Illu…

基于pt100温度计仿真_基于8pt网格的设计系统

基于pt100温度计仿真重点 (Top highlight)This article is the 2nd in a two part series — to the previous chapter in which I demonstrate how to establish an 8pt grid.本文是该系列文章的第二部分 ,这是上一章 的第二部分 ,在上一章中&#xff0…

利用 k8s 建立软件商店_为企业建立应用商店

利用 k8s 建立软件商店It’s June 2019. I’m sitting in a conference room in Research Triangle Park in North Carolina. At the end of the table are the two executives that have been tapped to lead a new endeavor on behalf of IBM’s $34 billion acquisition of …