为什么Google会调用前缀为"m"的变量,例如:
private int mSectionResourceId;
private int mTextResourceId;
Run Code Online (Sandbox Code Playgroud)
我在所有的例子中看到了它.但我不明白为什么他们这样做?
现在我有一些实例非常好的例子.如果一个没有前缀的被调用的变量,我需要写
public SimpleSectionedRecyclerViewAdapter(Context context, int sectionResourceId, int textResourceId,
RecyclerView.Adapter baseAdapter) {
this.sectionResourceId = sectionResourceId;
this.textResourceId = textResourceId;
Run Code Online (Sandbox Code Playgroud)
但如果我使用前缀我可以写
public SimpleSectionedRecyclerViewAdapter(Context context, int sectionResourceId, int textResourceId,
RecyclerView.Adapter baseAdapter) {
mSectionResourceId = sectionResourceId;
mTextResourceId = textResourceId;
Run Code Online (Sandbox Code Playgroud)
我觉得它更具可读性.谁能向我解释一下前缀的优缺点?
| 归档时间: |
|
| 查看次数: |
1628 次 |
| 最近记录: |