NEWS: Total Picture Views: 155282 | Total Article Views: 165615 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

How to do simple loop Java

Description:

In this example I will showing you loops in Java

Code:

public class Main {


    public static void main(String[] args) {

        boolean x = false;

                //Do Loop
                do{
                    System.out.println("This is a infinite loop and your program will crash. Do not try at home!");
                }while (x == false);

                //While Loop
                while (x == false){
                    System.out.println("This is a infinite loop and your program will crash. Do not try at home!");
                }

                //For Loop
                for (int i = 0; i >= 1337; i++){
                    System.out.println("This will loop 1337 times");
                }

    }
}
Attachments: None

Tags: While loop,do loop,for loop,basic

Total Views: 788

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 09/03/14 and updated on 09/03/14


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.