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 ...
随机推荐
- 【python之路28】模块python与excel
一.可使用的第三方库 python中处理excel表格,常用的库有xlrd(读excel)表.xlwt(写excel)表.openpyxl(可读写excel表)等.xlrd读数据较大的excel表时效 ...
- poj 2318 TOYS(计算几何 点与线段的关系)
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12015 Accepted: 5792 Description ...
- java swing调试时线程显示名字
一般有一个默认名字 但是具体运行到哪一个线程,需要猜 为了节约时间,提高效率 可以给线程写个中文名(因为默认就是英文,写中文,一眼就能挑出来) 以RTC定时器为例子 final TimerRtc ti ...
- 序列化form表单
// 序列化JSON字符串 $.fn.serializeObject = function () { let o = {}; let a = this.serializeArray(); $.each ...
- oracle建立job定期运行存储过程
1 首先查看 SQL> show parameter job NAME TYPE VALUE------------------------------------ ----------- -- ...
- Codeforces 849D.Rooter's Song
D. Rooter's Song time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- VS code 格式化插件, 仅需一步, 无须配置
1.安装Beautify 2.重启vscode后 按F1, 点击 Beautify 即可
- spring和mybatis整合遇到org.springframework.beans.factory.BeanDefinitionStoreException
今天对spring和mybatis整合进行练习,通过MapperScannerConfigurer进行mapper扫描 但是在进行单元测试的时候,死活就是报错,具体报错如下: org.springfr ...
- Django用户登陆以及跳转后台管理页面1
"""S14Djngo URL Configuration The `urlpatterns` list routes URLs to views. For more i ...
- DataGrid无故多一行空白行
DataGrid绑定datatable时, Datagrid.Itemsource=dt.DefaultView: 发现DataGRID会多处一行 解决如下: 对Datagrid的CanUserAdd ...