Android Studio prompts Private field 'mType' is assigned but never accessed reasons

Android Studio is a cool compiler, code hints before found a very strange, but the frustration has been not understand what he meant, but did not take too much notice being given no just suddenly realized, and that their own code is not standardized.

Private field 'mType' is assigned but never accessed




This sentence prompted mean:

It means mType variable definition used has never been requested.
That declaration or assignment, but you just never really used the private member variables.


If you comment out the following code
// int a = 10 * this.mType;
open
to let the variables involved in the operation, there is no prompt


The reason before writing the variable to be useful, but later changed under the code no spend, but stumbled upon this hint

The prompt only private modifier effective, think about the reason is very simple, because only in this private classes and inner classes effectively, all in the same file, so the compiler can be very simple to analyze whether the member variables involved in computing, If not, it said redundant, thus prompting.

The other modifiers may have to call in outside, they can not judge considered to be no problem.


Reproduced in: https: //my.oschina.net/zhouz/blog/213112

Guess you like

Origin blog.csdn.net/weixin_34242658/article/details/91728632