Local variables inside a method cannot be declared using visibility modifiers ( public , private , protected or by default), only class attributes can use these modifiers.
You can reuse the same variable names for different methods, this will not cause conflicts. It is good practice to define local variables in a method with different names from class attributes. To make sure:
public class Test { private String attribute1;
source share