File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes please explain the output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "please explain the output" Watch "please explain the output" New topic

please explain the output

Jhon Clay

Joined: Jul 16, 2007
Posts: 16


How can this be possible when the array values are diffrent
Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265


Review the way a foreach (advanced for loop) works for arrays, as opposed to standard for loops and I think you'll discover why you're getting the results you're seeing.

There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
jaspreet atwal
Ranch Hand

Joined: Sep 05, 2007
Posts: 52
Originally posted by chandan venkatesh:

You have made a mistake in println statement...

Still Learing..
Jhon Clay

Joined: Jul 16, 2007
Posts: 16
Thanks mates
should have been
for(int z : x) System.out.println( z);
I agree. Here's the link:
subject: please explain the output
It's not a secret anymore!