Saturday, Aug 8, 2026 · Practical tutorials, weekly

Loops in Java | Java Tutorial | For | While | For-Each | Do-While | Looping in Java

S Saurabh K May 23, 2020 1 min read 0 comments

Loops in any programming language are used to execute or run a set of instructions also called functions continually until the conditions become true.

In the Java programming language, basically, four types of loops:

  1. For Loops
  2. For-Each Loops
  3. While Loops
  4. Do-While Loops

1.For Loops:

public class Loops {

public static void main(String[] args){

// here first I will declare an array like

int[] array = {1,2,3,4,5,6,7,8};

for(int i =0;  i<8;  i++){

System.out.println(array[i]);

}

}

}

2.For-Each Loops

public class Loops {

public static void main(String[] args){

// here first I will declare an array like

int[] array = {1,2,3,4,5,6,7,8};

for(int i :array){

System.out.println(i);

}

}

}

To Know the Functionality of the Loops, Just watch the video, where you can find the step to step-wise tutorials on Loops Operations in Java:

3. While Loops:

public class Loops {

public static void main(String[] args){

// here first I will declare an array like

int[] array = {1,2,3,4,5,6,7,8};

int i =0;

while(i<array.length){

System.out.println(array[i]);

i++;

}

}

}

4. Do-While Loops:

public class Loops {

public static void main(String[] args){

// here first I will declare an array like

int[] array = {1,2,3,4,5,6,7,8};

int i =0;

do{

System.out.println(array[i]);

i++;

}

while(i<array.length){

}

}

}

Connect with us:

Share:
Saurabh K

Saurabh K

Author at Technical Speaks

Writes practical guides and tutorials to help readers build, rank, and grow online.

Leave a Comment

Newsletter

Stay ahead of the curve

Join readers getting our freshest tutorials and guides on web, SEO, tech & more — delivered weekly.