• Home
  • Courses

    About Courses

    • Core Java
    • JDBC
    JDBC

    JDBC

    Free
    Read More
  • Features
    • Portfolio
    • About Us
    • FAQs
  • Gallery
  • Blog
  • Contact
      • Cart

        0
    Hacked by Katib | Turkish Hacker | SpyHackerz.OrgHacked by Katib | Turkish Hacker | SpyHackerz.Org
    • Home
    • Courses

      About Courses

      • Core Java
      • JDBC
      JDBC

      JDBC

      Free
      Read More
    • Features
      • Portfolio
      • About Us
      • FAQs
    • Gallery
    • Blog
    • Contact
        • Cart

          0

      JAVA TECHNOLOGIES

      • Home
      • All courses
      • JAVA TECHNOLOGIES
      • Core Java
      LP CoursesJAVA TECHNOLOGIESCore Java
        • Lecture1.1
          What is Java? 30 min
        • Lecture1.2
          JDK Installation Steps 30 min
        • Lecture1.3
          First Program in Java 30 min
        • Lecture1.4
          C++ vs Java 30 min
        • Lecture1.5
          Java Comments 30 min
        • Lecture1.6
          Java Operators 30 min
        • Lecture1.7
          Java Loop Control 30 min
        • Lecture1.8
          Decision making 30 min
        • Lecture1.9
          Object Oriented Programming 30 min
        • Lecture1.10
          Objects and Classes 30 min
        • Lecture1.11
          Java Inheritance 30 min
        • Lecture1.12
          Static,non-static and final 30 min
        • Lecture1.13
          Abstract Class vs Interface 30 min
        • Lecture1.14
          Overloading vs Overriding 30 min

        Java Loop Control

        There may be a situation when we need to execute a block of code several number of times, and is often referred to as a loop. Java has very flexible three looping mechanisms.

        1. While Loop

        A while loop is a control structure that allows you to repeat a task a certain number of times.

        Syntax:

        while(Boolean_expression) {
        //Statements
        }

        When executing, if the boolean expression result is true then the actions inside the loop will be executed. This will continue as long as the expression result is true.

        [php]
        public class ForLoopExample {
        public static void main(String args[]) {
        int a = 1;
        while( a < 10 ) {
        System.out.println("value of a : " + a );
        a++;
        }
        }
        }
        [/php]

        Download Code Here

        2. Do-While Loop

        The DO … WHILE loop is almost similar to the WHILE loop, the difference is that in this loop, the execution of statements occur before checking of a condition.

        Syntax:

        do {
        //Statements
        }while(Boolean_expression);

        do…while loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.

        [php]
        public class DoWhileLoop {
        public static void main(String[] args) {
        int i =10;
        do{
        i=i+10;
        System.out.println("Loop Counter Variable=" +i);
        }while (i<10);
        }
        }
        [/php]

        Download Code Here

        3. For Loop

        For Loop checks the condition and executes the set of the statements , It is loop control statement in java. It contain the following statements such as “Initialization” , “Condition” and “Increment/Decrement” statement

        Syntax:
        for(initialization; Condition; update)
        {
        //Statements
        }

        [php]
        public class ForLoopExample{
        public static void main(String args[])
        {
        for(int i=0;i<10;i++)
        {
        System.out.println("Hello");
        }
        }
        }
        [/php]

        Download Code Here

        Prev Java Operators
        Next Decision making

        Leave A Reply Cancel reply

        Your email address will not be published. Required fields are marked *

        All Courses

        • JAVA TECHNOLOGIES

        Latest Courses

        Core Java

        Core Java

        Free
        JDBC

        JDBC

        Free
        logo-eduma-the-best-lms-wordpress-theme

        contactus@tech2our.com

        Company

        • About Us
        • Blog
        • Contact

        Links

        • Courses
        • Events
        • FAQs

        Support

        • Documentation
        • Forums
        • Language Packs

        Copyright © 2012-2017 Tech2Our.com. All Rights Reserved.

        • Privacy
        • Terms
        • Sitemap