Controlling Execution
来源:互联网 发布:淘宝领劵推广真的假的 编辑:程序博客网 时间:2024/06/06 06:51
Return
The return keyword has two purposes: It specifies what value a method will return (if it doesn’t have a void return value) and it causes the current method to exit, returning that value. If you do not have a return statement in a method that returns void, there’s an implicit return at the end of that method, so it’s not always necessary to include a return statement. However, if your method states it will return anything other than void, you must ensure every code path will return a value.
Break只能跳出一重循环(经测试验证)。
The switch statement requires a selector that evaluates to an integral value, such as int or char.
The infamous “goto”
Although goto is a reserved word in Java, it is not used in the language; Java has no goto. However, it does have something that looks a bit like a jump tied in with the break and continue keywords. It’s not a jump but rather a way to break out of an iteration statement. The reason it’s often thrown in with discussions of goto is because it uses the same mechanism: a label.
The only place a label is useful in Java is right before an iteration statement.And that means
right before—it does no good to put any other statement between the label and the iteration. And the sole reason to put a label before an iteration is if you’re going to nest another iteration or a switch (which you’ll learn about shortly) inside it. That’s because the break and continue keywords will normally interrupt only the current loop, but when used with a label, they’ll interrupt the loops up to where the label exists.(使用lable的原因是需要跳出多重循环,而break与continue只能跳出单重循环)The same rules hold true for while:
1. A plain continue goes to the top of the innermost loop and continues.
2. A labeled continue goes to the label and reenters the loop right after that label.
3. A break “drops out of the bottom” of the loop.
4. A labeled break drops out of the bottom of the end of the loop denoted by the label.
1. A plain continue goes to the top of the innermost loop and continues.
2. A labeled continue goes to the label and reenters the loop right after that label.
3. A break “drops out of the bottom” of the loop.
4. A labeled break drops out of the bottom of the end of the loop denoted by the label.
- Controlling Execution
- Controlling Execution
- Java Note - Controlling Execution
- Day11-36.Controlling Execution
- 处理教材:Controlling Execution of "Thinking in Java"
- 《JAVA编程思想》学习备忘(第135页:Controlling Execution)
- Controlling Companies
- Controlling Area
- Controlling serialization
- Controlling Companies
- Controlling Companies
- controlling nginx
- fjnu 1148 Controlling Companies
- Controlling IntelliSense Through Macros
- Controlling application separation
- Controlling Core Files
- 【其他】【USACO】Controlling Companies
- maya remote controlling
- Operators
- 封装微软TTS实现web系统文本转语音
- C++.Homework. Operator overloading.02
- young氏矩阵
- struts2
- Controlling Execution
- 单链表
- jquery tree table js 试用
- linux内核的调度策略
- Initialization & Cleanup
- linux-内存分配和动态库静态库
- 服务器启动时停留在grub提示处的解决方法
- 生产者消费者模型的实现
- Access Control