0

Hi all,

I'm working on a program for my data handling class and I have a quick question. I'm trying to write a method that prints a range of elements in an array. I have written it in such a way that I create a new, smaller array with the specified first and last element, but I was wondering if there way to do this with an enhanced for statement. It seems like it would be so much more elegant, but I can't seem to find any sample code for this. There is more to the program that this and I don't want anyone to do this for me, I'm just looking for a way to write the enhanced for statement using an upper and lower bound. Thanks for any replies.

Steve

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by snprime
0

Nope! If you only want to loop over a "sub array" the "old" for loop is better. An alternative, if it is an Object array, is to stop looping (break) at the first null object.

0

Nope! If you only want to loop over a "sub array" the "old" for loop is better. An alternative, if it is an Object array, is to stop looping (break) at the first null object.

That's what I kind of figured. Thanks for the help anyways. I managed to get it anyway.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.