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

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. python时间处理,datetime中的strftime/strptime

    python中datetime模块非常好用,提供了日期格式和字符串格式相互转化的函数strftime/strptime 1.由日期格式转化为字符串格式的函数为: datetime.datetime.s ...

  2. LINUX用户身份切换

    Su 命令作用 su的作用是变更为其它使用者的身份,超级用户除外,需要键入该使用者的密码. 使用方式 su [-fmp] [-c command] [-s shell] [--help] [--ver ...

  3. 【vue】vue-znly

    老规矩,放下博主的项目地址:https://github.com/wohaiwo/vue-znly 我一直在想给那些开源者取什么名字比较好,怎样才对得起他们开源项目的精神,后来想想,还是叫博主吧.有的 ...

  4. jquery判断元素是否出现在可视区

      在我们的日常开发中,经常会遇到当元素出现在可视区的时候需要去出发某一事件的情况.我最近在优化环球网首页的时候,将非可视区的代码全部放入到webComponent中.打算当这个元素出现在可视区的时候 ...

  5. Ubuntu 18.04 美化

    Ubuntu 18.04 美化 sudo apt install gnome-tweak-tool sudo apt install gnome-shell-extensions sudo apt i ...

  6. TZ_11_Spring-Boot的整合SpringMvc和MyBatis

    1.整合SpringMVC 虽然默认配置已经可以使用SpringMVC了,不过我们有时候需要进行自定义配置. 1>修改方式 通过application.yaml 此名字不需要使用@Propert ...

  7. [转]深入理解ajax系列——响应编码

    我们接收到的 ajax 响应主体类型可以是多种形式的,包括字符串String.ArrayBuffer对象.二进制Blob对象.JSON对象.javascirpt文件及表示 XML文档的Document ...

  8. fedora input problem...

    davelv最近很郁闷,因为他在Fedora 下用Eclipse写程序的时候,一旦有Eclipse实现了自动提示.代码补齐等功能后,键盘就失去相应,必须根据点右键或者切换窗口才能输入.就上网查,发现是 ...

  9. 一致性Hash算法原理,java实现,及用途

    学习记录: 一致性Hash算法原理及java实现:https://blog.csdn.net/suifeng629/article/details/81567777 一致性Hash算法介绍,原理,及使 ...

  10. UvaLive1347

    Programming contests became so popular in the year 2397 that the governor of New Earck — the largest ...