How can I iterate over a Set/HashSet without the following? Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); } 8 Answers 8
I’m trying to use a break statement in a for loop, but since I’m also using strict subs in my Perl code, I’m getting an error saying: Bareword “break”...
Is there a way in Java’s for-each loop for(String s : stringArray) { doSomethingWith(s); } to find out how often the loop has already been processed? Aside from using...
I need to execute a command 100-200 times, and so far my research indicates that I would either have to copy/paste 100 copies of this command, OR use a...
I have always wondered if, in general, declaring a throw-away variable before a loop, as opposed to repeatedly inside the loop, makes any (performance) difference? A (quite pointless) example...
I know that recursion is sometimes a lot cleaner than looping, and I’m not asking anything about when I should use recursion over iteration, I know there are lots...
I know how to use both for loops and if statements on separate lines, such as: >>> a = [2,3,4,5,6,7,8,9,0] ... xyz = [0,12,4,6,242,7,9] ... for x in xyz:...
I have a loop starting with for i in range(0, 100). Normally it runs correctly, but sometimes it fails due to network conditions. Currently I have it set so...
This question already has answers here: Equivalent of “continue” in Ruby (7 answers) Closed 5 years ago. In Ruby, how do I skip a loop in a .each loop,...
I am trying to loop from 100 to 0. How do I do this in Python? for i in range (100,0) doesn’t work. 17 Answers 17