[java] Problems with local variable scope. How to solve it?