Variable declaration

HiIm not clear as why this code works class a{ void meth() {int i;i = 0; }}and this does notclass a{int i;i = 0;}rgds
[236 byte] By [kingsingh] at [2007-9-30 20:47:37]
# 1
class a{int i;i = 0;}i =0; is outside any method. Variable declarations can be outside any method, but not other statements.
BIJ001 at 2007-7-7 2:20:45 > top of Java-index,Administration Tools,Sun Connection...
# 2
But then why can you go like this...class{int i = 0;}
RachelSwailes at 2007-7-7 2:20:45 > top of Java-index,Administration Tools,Sun Connection...
# 3
It is a declaration with initial value assignment.
BIJ001 at 2007-7-7 2:20:45 > top of Java-index,Administration Tools,Sun Connection...