同上一章,本章依然比较简单、基础,因此只是做一些总结性的笔记。

1、 不像C和C++那样(0是假,非零为真),Java不允许用一个数字作为boolean值。

2、 C中,为了给变量分配空间,所有变量的定义必须在代码块前面。而C++和Java中没有这个限制,它允许更加自然的代码

    风格,而且使得代码更容易理解。

3、 使用Foreach语法,我们不必创建一个用来遍历各个项的整型值,foreach自动的为我们提供每一个项。

4、 如果在返回值为void的方法中没有return语句,那么它隐式地在方法的结尾处返回,因此return语句并不总是必须的。然

    而,如果方法声明返回任何非void类型,我们必须保证代码的每个执行路径返回恰当的值。

5、 Java允许在循环体之前设置标签,并且循环体和标签之间不能有任何语句,它的主要作用是可以跳出多层循环,而break和

    continue只能打断当前的循环。

6、 The switch statement is a clean way to implement multiway selection(i.e., selecting from among a

number of different execution paths), but it requires a selector that evaluates to an integral value, such

as int or char. If you want to use, for example, a string or a floating point number as a selector, it won’t

work in a switch statement. For non-integral types, you must use a series of if statements. BTW, Java

SE5’s new enum feature helps ease this restriction, as enums are designed to work nicely with switch.

TIJ——Chapter Four:Controlling Execution的更多相关文章

  1. TIJ——Chapter Twelve:Error Handling with Exception

    Exception guidelines Use exceptions to: Handle problems at the appropriate level.(Avoid catching exc ...

  2. Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(五)之Controlling Execution

    In Java, the keywords include if-else,while,do-while,for,return,break, and a selection statement cal ...

  3. TIJ——Chapter Two:Everything Is an Object

    If we spoke a different language, we would perceive a somewhat different world. Ludwig Wittgenstein( ...

  4. TIJ——Chapter One:Introduction to Objects

    ///:~容我对这个系列美其名曰"读书笔记",其实shi在练习英文哈:-) Introduction to Objects Object-oriented programming( ...

  5. TIJ——Chapter Eleven:Holding Your Objects

    Java Provides a number of ways to hold objects: An array associates numerical indexes to objects. It ...

  6. TIJ——Chapter Eight:Polymorphism

    The twist |_Method-call binding Connecting a method call to a method body is called binding. When bi ...

  7. TIJ——Chapter Seven:Reusing Classes

    Reusing Classes 有两种常用方式实现类的重用,组件(在新类中创建存在类的对象)和继承. Composition syntax Every non-primitive object has ...

  8. TIJ——Chapter Five:Initialization & Cleanup

    Method overloading |_Distinguishing overloaded methods If the methods hava the same name, how can Ja ...

  9. TIJ——Chapter Fourteen:Type Information

    Runtime type information(RTTI) allows you to discover and use type information while a program is ru ...

随机推荐

  1. Luogu P1073 最优贸易(最短路)

    P1073 最优贸易 题意 题目描述 \(C\)国有\(n\)个大城市和\(m\)条道路,每条道路连接这\(n\)个城市中的某两个城市.任意两个城市之间最多只有一条道路直接相连.这\(m\)条道路中有 ...

  2. Layui表格数据重新载入_表格搜索

  3. 【笔记】LR中设置检查点

      我们为什么需要在LR中设置检查点?? 我们在录制编写脚本后,通常会进行回放,如果回放通过没有错误.我们就认为脚本是正确的.那么LR怎么区分脚本是否回放正确:基本上所有脚本回放错误都是因为 404错 ...

  4. Spring MVC 搭建web项目示例

    环境为Eclipse 1:新建Dynamic web project  : springMvcDemo 2:下载spring的jar包,把jar包复制到WEB-INF/lib目录下 3.添加配置文件w ...

  5. springmvc jsp向controller传参,一直为null

    怎么检查都无解 重启电脑好了

  6. 实用Jupyter Notebook扩展工具——提升你的工作效率

    Jupyter Notebook 现已成为数据分析,机器学习的必备工具.因为它可以让数据分析师集中精力向用户解释整个分析过程.通过安装一些扩展工具,可以让你在Jupyter Notebook上的工作效 ...

  7. List的深度序列化Demo

    今天项目中出现了这个问题...就是使用一个List去进行其他的操作,生成一个新的List.但是却将原来的List的值也给改了...这应该是引用传递的问题,查了资料发现这是浅拷贝造成的.(ps:使用ad ...

  8. JS 防止重复提交

    JS 防止重复提交表单 利用flag自定义设置,缺点就是当页面有很多类似操作时,每次需要一个 方法二: var newtime = 0; function sub(){ var Today = new ...

  9. webpack 4.X 创建 react项目

    1. 新建一个文件夹2. 运行 npm init -y 快速初始化项目3. 在跟目录创建src文件夹 dist文件夹4. 在src下创建 index.html main.js // index.htm ...

  10. python学习笔记10--协程、IO、IO多路复用

    本节内容 一.协程 1.1.协程概念 1.2.greenlet 1.3.Gevent 1.4.协程之爬虫 1.5.协程之socket 二.论事件驱动与异步IO 三.IO 3.1.概念说明 3.2.IO ...