title: Java Iterator Impose Condition on Next()
body: <p>I'm a little confused about iterators in Java. How do I make next() only return certain values? Like say I have a boolean array of 10 elements, and I only want to return those that are true. Do I put a conditional in the next() method that checks for that condition and returns when it is met? Or do I check for the condition when I actually use the iterator and keep calling next() until I get a suitable value, and then use that value? </p>
  
  <p>Similarly if I have an array of ints, and I want to create a string representation of the array where each element is separated by a space, but I only want to use negative elements. If I want to do this with an iterator, do I check for the negative element in the next() method and only return next values that are negative, or do I check when I'm making the string representation, and keep calling next() until I get a negative value, and then add that value to the string?</p>
  
  <p>Thanks!</p>