Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道,在java中组织类成员的正确方法是什么?我们应该先从公共成员开始,然后是私人成员还是私人成员?
Member is an interface that reflects identifying information about a single member (a field or a method) or a constructor.(甲骨文官方文档)
Member is an interface that reflects identifying information about a single member (a field or a method) or a constructor.
因此,我建议每次有可能时,您都应该将自己fields设为私有并setters and getters为他们制作。至于方法 - 我真的不确定你是否必须根据事实来组织它们,如果它们是public或private
fields
setters and getters
public
private