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 ...
随机推荐
- 在VS中编译Opencascade6.6.0
话说,OpenCASCADE团队真的很给力,版本更新速度也是嗖嗖地.依稀记得上次编译OCC,那时候的第三方库.OCC本身几何引擎库,全都得自己编译. 于是,编译过程之艰苦也就可想而知了.最近重换系统, ...
- 2019-5-21-asp-dotnet-core-图片在浏览器没访问可能原因
title author date CreateTime categories asp dotnet core 图片在浏览器没访问可能原因 lindexi 2019-05-21 11:24:43 +0 ...
- UVA11916 Emoogle Grid
Emoogle Grid You have to color an M × N (1 ≤ M, N ≤ 108 ) two dimensional grid. You will be provided ...
- Liferay 7:Liferay内部博客地址
想要了解Liferay最新功能和特性,可以看一看. 非常实用,都是Liferay开发者写的: https://web.liferay.com/zh/community/blogs/all
- Vue-cli3.x中使用Axios发送跨域请求的配置方法
Vue-cli3.x中使用Axios发送跨域请求的配置方法 安装axios npm i axios -s main.js中引入 import axios from 'axios' //将axios挂载 ...
- Eclipse配置Maven详细教程
一.使用eclipse自带的maven插件 首先,现在下载Eclipse Mars之后的版本,基本上都自带了maven插件,无需自己再安装maven. 有几个注意点: 1.默认的本地仓库的目录是在C: ...
- MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request; // 转换成多部分request异常
原来是需要在springmvc中配置 <!-- multipartResolver上传文件 --> <bean id="multipartResolver" cl ...
- Linux下根目录root扩容
参考博客:https://blog.csdn.net/qq_36527339/article/details/81772996 1.首先虚拟机关机 —> 选中要扩容的虚拟机 —>编辑虚拟机 ...
- 一段简单简介的JAVA内存分页代码
1.原因 工作中有的时候我们要处理的分页是无法全部用数据库去处理的,因为有些业务数据需要计算,所以我们需要把数据拿到程序中去分页 2.代码 //前端传入分页参数 Pageable pageable = ...
- python自动化---各类发送邮件方法及其可能的错误
一.发送文本邮件 可能的问题1.:需要注意,目前QQ邮箱来讲,不能收到完整的邮件,即有些内容不能显示,最好全部使用网易邮箱: 可能的问题2.:在以往的文本邮件发送中,只写了 msg = MIMETex ...