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: 318
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.
- public class Test {
- public static void main (String []args) {
- int i = 0;
-
- for(int j = 1; j <= 5; j++) {
- if(j == 1 || j == 5) {
- i = 4;
- }
- else {
- i = 1;
- }
- for(int x = 0; x < i; x++) {
- System.out.print("**");
- }
- System.out.println();
-
- }
- }
- }
© Stack Overflow or respective owner