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 nested loops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "nested loops" Watch "nested loops" New topic

nested loops

Gerald Nah Haw Yuan

Joined: Aug 07, 2003
Posts: 7
Using nested loops, how do i print the following output :
from an array like int[] a={1,2,3,4,5};
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Is it a homework?


[ August 08, 2003: Message edited by: siu chung man ]

Francis Siu
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
I thought this question was answered, but while both examples provide the intended output, they obviously don't provide the intended functionality. The first example is completely dependent upon the contents of the array being what it is because j is compared to the value contained by the array rather than the index, if you change the contents it will give you an error. I very much doubt that's what was intended. The second one doesn't even use an array, and question specifically said it was to be done from an array.
I believe the solution you are seeking would be more along the lines of...
I agree. Here's the link:
subject: nested loops
It's not a secret anymore!