问题 This question was asked from me in an interview. Can we declare private variables inside a public method? If can, can we access variables through the public method? I tried with java but it does not allow to define private variable inside a method why is that? public class GetUser { public String getUserName(){ private String user="David"; return user; }} 回答1: No, you can not. Variables inside method are considered local and can't have modifiers. You can have private fields in a class, but