Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Loop (https://www.askmehelpdesk.com/showthread.php?t=772923)

  • Oct 27, 2013, 11:50 AM
    aalabb01
    Loop
    I wrote two loops, my problem is if the program execute the first loop then the second it works fine. However, when it finishes from the second loop first time then to goes back to the first loop it will not get into the second loop again. it will iterate inside the first loop until the end.
    in the following is my code and the result I get:

    try { int n=0; int I=0;
    String line;

    char c=0;
    char [] arr1=new char[6];

    while ((line = br.readLine()) != null ) {
    if(n<1250) {
    n++;
    System.out.print("0"+n+"\n");
    for(;c != ',';i++){

    c=line.charAt(i);
    arr1[i]=c;
    System.out.print(arr1[i]);
    jTextArea7.append(c+"");
    }
    }
    }
    }


    result:

    01 //result for the first loop
    vhigh,02 //result for the next loop
    03//goes back to the first loop (until here fine)
    //but after this point I want the compiler to execute the second loop again, it stay //iterating within the first loop
    04
    05
    06
    07
    08
    09
    010
    011
  • Nov 30, 2013, 09:20 AM
    Scleros
    What is the value of 'c' each iteration?

  • All times are GMT -7. The time now is 05:09 AM.