Q about( for) and (if) statements

Hi

I am not sure whether i am right or not, but i found that (for) or (if) statement cannot be written outside constructors and when i try to write it (illegal epxpression start ) message appears.

my Q is it must be written inside constructor ?

Actually i saw a program with (if) and (for) outside constructor

[336 byte] By [scrolldowna] at [2007-11-26 22:42:30]
# 1
those statements are legal code in any method. constructors are methods. initializers are, s well. where have you seen this code? show us
georgemca at 2007-7-10 11:58:04 > top of Java-index,Java Essentials,New To Java...
# 2
You cannot write them outside of methods, constructors, or initializer blocks. There's nothing particular about "for" or "if" statements in this regard.
warnerjaa at 2007-7-10 11:58:04 > top of Java-index,Java Essentials,New To Java...
# 3
Suggestion: when you have a question about your code, the mosteffective thing to do is post a short complete example. Does that makesense to you? Will you do it the next time?
DrLaszloJamfa at 2007-7-10 11:58:04 > top of Java-index,Java Essentials,New To Java...