You might think of it this way: A class has "state" in the form of variables, and "behavior" in the form of methods. When you want to do something -- like execute a loop -- that's behavior, so it needs to be inside a method body.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org