Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange behavior for enhanced ForLoop.

 
Steven Rodeo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic