for语句 : For循环 « 流程控制 « Java 教程

En
Java 教程
1. 语言基础
2. 数据类型
3. 操作符
4. 流程控制
5. 类定义
6. 开发相关
7. 反射
8. 正则表达式
9. 集合
10. 线
11. 文件
12. 泛型
13. 本土化
14. Swing
15. Swing事件
16. 二维图形
17. SWT
18. SWT 二维图形
19. 网络
20. 数据库
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web服务SOA
27. EJB3
28. Spring
29. PDF
30. 电子邮件
31. 基于J2ME
32. J2EE应用
33. XML
34. 设计模式
35. 日志
36. 安全
37. Apache工具
38. 蚂蚁编译
39. JUnit单元测试
Java
Java 教程 » 流程控制 » For循环 
4. 6. 1. for语句

The for statement is like the while statement, i.e. you use it to create loop. The for statement has following syntax:

for init ; booleanExpression ; update ) {
    statement (s)
}
  1. init is an initialization that will be performed before the first iteration.
  2. booleanExpression is a boolean expression which will cause the execution of statement(s) if it evaluates to true.
  3. update is a statement that will be executed after the execution of the statement block.
  4. init, expression, and update are optional.

The for statement will stop only if one of the following conditions is met:

  1. booleanExpression evaluates to false
  2. A break or continue statement is executed
  3. A runtime error occurs.
4. 6. For循环
4. 6. 1. for语句
4. 6. 2. For statement in detail
4. 6. 3. A loop allows you to execute a statement or block of statements repeatedly
4. 6. 4. 数值for循环
4. 6. 5. 无限环
4. 6. 6. initialization_expression :定义两个变量在for循环
4. 6. 7. 声明多个变量在for循环
4. 6. 8. Multiple expressions in for loops
4. 6. 9. To omit any or all of the elements in 'for' loop: but you must include the semicolons
4. 6. 10. Keeping the middle element only in for loop
4. 6. 11. Using the Floating-Point Values as the control value in a for loop
4. 6. 12. 嵌套的循环
4. 6. 13. Java's 'labeled for' loop
4. 6. 14. 打印出金刚石
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.