TIJ——Chapter Four:Controlling Execution
同上一章,本章依然比较简单、基础,因此只是做一些总结性的笔记。
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的更多相关文章
- TIJ——Chapter Twelve:Error Handling with Exception
Exception guidelines Use exceptions to: Handle problems at the appropriate level.(Avoid catching exc ...
- 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 ...
- TIJ——Chapter Two:Everything Is an Object
If we spoke a different language, we would perceive a somewhat different world. Ludwig Wittgenstein( ...
- TIJ——Chapter One:Introduction to Objects
///:~容我对这个系列美其名曰"读书笔记",其实shi在练习英文哈:-) Introduction to Objects Object-oriented programming( ...
- TIJ——Chapter Eleven:Holding Your Objects
Java Provides a number of ways to hold objects: An array associates numerical indexes to objects. It ...
- TIJ——Chapter Eight:Polymorphism
The twist |_Method-call binding Connecting a method call to a method body is called binding. When bi ...
- TIJ——Chapter Seven:Reusing Classes
Reusing Classes 有两种常用方式实现类的重用,组件(在新类中创建存在类的对象)和继承. Composition syntax Every non-primitive object has ...
- TIJ——Chapter Five:Initialization & Cleanup
Method overloading |_Distinguishing overloaded methods If the methods hava the same name, how can Ja ...
- TIJ——Chapter Fourteen:Type Information
Runtime type information(RTTI) allows you to discover and use type information while a program is ru ...
随机推荐
- Redis学习01——介绍与搭建环境
Redis学习01介绍与搭建环境一简介二yum配置已经配置了的可以跳过三安装gcc四安装redis1 上传Redis到linux中2 解压到usrlocal下3 编译redis4 安装redis5 拷 ...
- Java是如何实现跨平台的
一.Java是如何实现跨平台的 1.我们编写的Java源码,编译后会生成一种 .class 文件,称为字节码文件 2.Java虚拟机JVM就是负责将字节码文件翻译成特定平台下的机器码然后运行.也就是说 ...
- java知识点---文件分隔符
本篇讲述java编程中,怎样解决跨平台时,因不同系统中分隔符不同导致的文件或路径找不到的问题 首先来看两个例子: 一.linux系统和windows系统中的文件路径: Linux系统: Windows ...
- DTD约束与schema约束的不同
本篇笔记了解------Schema约束的语法 ------可以参考W3school之Schema教程. Schema:是基于 XML 的 DTD 替代者,用于描述XML文档结构.支持XML 命名空间 ...
- JavaBean与Map的相互转换
package com.bizvane.utils.tools; import java.lang.reflect.Field; import java.util.Arrays; import jav ...
- eclipse2018整合tomcat9
eclipse2018整合tomcat9 选择 Windows --> preferences --> server --> runtime environmen:点击“add”按钮 ...
- 两张图搞清composer install与update区别 - 今日头条(www.toutiao.com)
composer update : 主要是在开发阶段使用,根据我们在composer.json文件中指定的内容升级项目的依赖包. composer install : 主要是在部署阶段使用,以便在生产 ...
- 阿里云合作伙伴峰会SaaS加速器专场 | 商业加持,迈进亿元俱乐部
导语:本文中,阿里云智能运营专家朱以军从宏观角度分析了SaaS市场的机遇和挑战,重点介绍了阿里云的商业操作系统.同时,阿里云SaaS加速器也在招募更多ISV合作伙伴和我们一起共创专注面向未来的应用,用 ...
- Visual studio加载项目时报错 尚未配置为Web项目XXXX指定的本地IIS,需要配置虚拟目录。解决办法。
在SVN上下载工程项目.使用visual studio打开时,出现如下提示: 查找相关资料,解决办法如下: 使用记事本打开工程目录下的.csproj文件.把<UseIIS>False< ...
- Codeforces 455C
题目链接 C. Civilization time limit per test 1 second memory limit per test 256 megabytes input standard ...