aspose file tools*
The moose likes Beginning Java and the fly likes Strange behavior for enhanced ForLoop. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Strange behavior for enhanced ForLoop." Watch "Strange behavior for enhanced ForLoop." New topic
Author

Strange behavior for enhanced ForLoop.

Steven Rodeo
Ranch Hand

Joined: Mar 06, 2008
Posts: 72


The above prints :

: 30 : 40 : 50 : 60 : 70 : 80 : 90 : 100 : 30 : 40 : 50 : 60 : 70 : 80 : 90 : 100


But if I uncomment the System.out.println. It prints

: 30 : 40 : 50 : 60 : 70 : 80 : 90 : 100

Scratching my head ;-)
_SM
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

Not on my computer it doesn't. It prints this:

which is what you would expect. I suspect you weren't running the code you thought you were running.
Steven Rodeo
Ranch Hand

Joined: Mar 06, 2008
Posts: 72
hmm not possible, I am using Eclipse, right click on the file and fired it off!.

I did try several times, now I did the archaic command line (javac / java ) way still the same result.

I am running this on a mac.

java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)

Not sure if this has any bearing on the result.

_SM
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

I should mention that I commented out line 3 in your posted code because I don't have the AtomicIntegerArray class on my machine.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Then try to clean your project. I've experienced similar problems and usually it can be solved by cleaning your project and/or searching for the file and deleting the compiled version.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange behavior for enhanced ForLoop.