Print Out Counter in Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CodeTilYaDrop
    New Member
    • Aug 2007
    • 66

    #1

    Print Out Counter in Program

    Hi,

    I can not seem to get my counter to print out in Java. I have it setup to count each iteration of a loop in my program. Then, I want to print out the number of iterations of the loop.

    I have this statement after my loop in the program:

    iteration_count er++

    Then, I want to print it out the amount of times it went through the loop. I used this code:

    System.out.prin tln("Total iterations:" + interation_coun ter);

    What am I doing wrong with this??? I can not get it to work. Anyone have an example to help me out with printing out the counter. thanks
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by CodeTilYaDrop
    Hi,

    I can not seem to get my counter to print out in Java. I have it setup to count each iteration of a loop in my program. Then, I want to print out the number of iterations of the loop.

    I have this statement after my loop in the program:

    iteration_count er++

    Then, I want to print it out the amount of times it went through the loop. I used this code:

    System.out.prin tln("Total iterations:" + interation_coun ter);

    What am I doing wrong with this??? I can not get it to work. Anyone have an example to help me out with printing out the counter. thanks
    Post the code you used then. Using code tags.

    Comment

    • CodeTilYaDrop
      New Member
      • Aug 2007
      • 66

      #3
      I got it to work. I set it as a variable, and I did not have it in the loop exactly. I looked at some other examples. Problem solved.....

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by CodeTilYaDrop
        I got it to work. I set it as a variable, and I did not have it in the loop exactly. I looked at some other examples. Problem solved.....
        Good to know you fixed it. If you'd posted your code I'm sure we could have helped as well.

        Comment

        Working...