473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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_counter++

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

System.out.println("Total iterations:" + interation_counter);

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
Oct 8 '07 #1
3 1616
r035198x
13,262 8TB
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_counter++

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

System.out.println("Total iterations:" + interation_counter);

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.
Oct 8 '07 #2
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.....
Oct 9 '07 #3
r035198x
13,262 8TB
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.
Oct 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michelle | last post by:
I have tried every variation of the "onchange" statement below without any actual reloading of the page. I am hoping that the PHP PRINT statement is constructed wrong, otherwise it is javaScript...
16
by: VISHNU VARDHAN REDDY UNDYALA | last post by:
Hi, Could anyone over here, write a program in C using only for loop to print the following output * *** ***** ******* ********* ***********
1
by: quirdan | last post by:
Hi, I am after some advice about which data structures I should use. I'm developing a program and I am at the point where all the strings are being generated and printed one by one with...
5
by: Carl Witte | last post by:
Hello. I'm stuck. I've got a form I need to print to a manual feeder on a shared laser printer. This will get me to the printer but I can't seem to figure out how to print it to a specific bin. ...
1
by: chriswilliams | last post by:
This code prints output in rows like this: ****** ****** ****** How to make print in blocks like this? ***** ***** ****** ***** ***** ****** ***** ***** ***** start= int...
12
by: waterdriven | last post by:
Hello; I am a newbie. A homework assignment was assigned and I am having trouble getting started. The assignment reads: Write a program to print out the binary value of a 16 bit number.
3
by: vileoxidation | last post by:
Hello, and thanks for any help in advance! Basically, as the title says, I am looking for a way to print the number of times the user gave the program an input, and then also print the average of...
3
by: lilly07 | last post by:
I am new to perl. I would like to open a file and print 2,6,10,14.. etc lines of that file content. How to do it? I amm able to open a file and print the contetnts as below: #!usr/bin/perl ...
11
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.