Types of Nested Loops in JAVA

Posted by dominoos on Stack Overflow See other posts from Stack Overflow or by dominoos
Published on 2010-05-08T07:40:53Z Indexed on 2010/05/08 7:48 UTC
Read the original article Hit count: 290

Filed under:
|
|
|
|

Hi guys. I have a simple question. I have to find out many nested loops as possible in java. I have something like for loop and if statement inside. i know that we can do like if{if{if{if{ something like that too. just need some more idea of more types of nested loops.

if you can write down some examples. I'll be very glad. thank you.

  1. public class Test {
  2. public static void main (String []args) {
  3. int i = 0;
    1. for(int j = 1; j <= 5; j++) {
  4. if(j == 1 || j == 5) {
  5. i = 4;
  6. }
  7. else {
    1. i = 1;
    2. }
    3. for(int x = 0; x < i; x++) {
    4. System.out.print("**");
    5. }
    6. System.out.println();
      1. }
    7. }
    8. }

© Stack Overflow or respective owner

Related posts about java

Related posts about loop