Java Base for Loop

Source: Internet
Author: User

Http://www.verejava.com/?id=16992632674123

/*for 循环定义 :for(初始化变量;判断条件;更新循环变量){} 执行过程:1. 初始化变量2. 执行判断条件, 如果true 继续执行,执行完后, 更新循环变量, 再判断条件,   直到 判断条件为 false 退出循环*/public class ForStatement{    public static void main(String[] args)    {        //打印出0-9        /*            执行过程:            1. 初始化i=0;            2. 执行 i<10 如果为true 执行 System.out.println(i);                执行完后 i++ 再跟 i<10 判断 以此循环直到 i>=10 退出循环        */        for(int i=0;i<10;i++)        {            System.out.println(i);        }    }}/*  while, do while, for 循环的比较  1. while 循环是先判断再循环, do while 是先执行再判断  2. for 循环一般用于下标值访问的情况  问题:  如果我们要在循环的时候中途终止,或退出需要用到 break ,continue*/

Http://www.verejava.com/?id=16992632674123

Java Base for Loop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.