If I try to assign a value to a variable in a class, but outside a method I get an error.
class one{ Integer b; b=Integer.valueOf(2); }
b
This is the way java works, you cannot add non-declaration code (sorry i don't know the correct term) inside the class, that code should be inside methods.