aspose file tools*
The moose likes Java in General and the fly likes you'd think this'd work but.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "you Watch "you New topic
Author

you'd think this'd work but....

Richard Shelly
Greenhorn

Joined: Oct 03, 2005
Posts: 24
it doesnt! (is anyone really surprised!?)

heres the deal, i have a class, with a integer variable called ticketCount.
ticketCount is in a loop to read from a file, and increment, thus counting the number of tickets. strangely, it seems this increment never happens. despite every other command in the loop working. (and no, its not commented out!)


<a href="http://www.somethingfm.net/" target="_blank" rel="nofollow">somthingFM</a> BOOYAH
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
Post your code. You are probably, in some way or another, short circuting
your loop (looping back to the top) before you ever get to your counter.
Or your counter is inside of an if/switch/whatever statement that never
gets accessed. But incrementing a variable inside of a loop definately
does work.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Let me guess, you are using

counter = counter++;

If so, take a very close look at how the post increment operator works.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Nice guess Ilja
I could guess some very strange things too, but prefer to wait for Richard to post his loop.


[My Blog]
All roads lead to JavaRanch
Richard Shelly
Greenhorn

Joined: Oct 03, 2005
Posts: 24



Ticket is simply a class that holds an int(ticket number), an int array(the lottery numbers), and a string(suburb in which it was bought).
Richard Shelly
Greenhorn

Joined: Oct 03, 2005
Posts: 24
its cool!! it works now!! booyah!!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

That's cool. That would also be cool to tell us where your blunder is
Richard Shelly
Greenhorn

Joined: Oct 03, 2005
Posts: 24
well, clearly, i redefined tickets in the constructor (possibly me just assuming Eclipse is smarter than me.
 
jQuery in Action, 2nd edition
 
subject: you'd think this'd work but....