魅力程序猿

  • 首页
  • Java
  • Android
  • APP
    • 扑克计分器
    • Video Wallpaper
  • 联系我
  • 关于我
  • 资助
道子
向阳而生
  1. 首页
  2. Android
  3. 正文

Android Studio:Field can be converted to a local variable

2018年5月9日 8148点热度 0人点赞 0条评论

1. 解析

Field can be converted to a local varible 的完整说明是:

This inspection searches for redundant class fields that can be replaced with local variables. If all local usages of a field are preceded by assignments to that field, the field can be removed and its usages replaced with local variables.

意思是检测到这个变量可以使用局部变量替换,建议删除并写成局部变量。就是其他地方也没有使用到它,没有必要声明成成员变量。

其实,你也可以不用管,改了也就是code更加合理。

2. 解决方案

删除private XXX XXX; 这句,并在使用的地方直接声明和实例化。

在 Android Studio for Mac 里可以直接使用快捷键 alt + enter 来快速转换成局部变量。

 

标签: Field can be converted to a local variable
最后更新:2018年5月9日

daozi

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
搜索
联系方式

QQ群:179730949
QQ群:114559024
欢迎您加入Android大家庭
本人QQ:136049925

赐我一丝安慰
给我一点鼓励

COPYRIGHT © 2023 魅力程序猿. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备15000477号