Issue
In Android Studio I created a code where I declare
int variablename = 1
I later perform if (string.contains("hello")){ variablename = 0 }
and later if ( variablename == 0 ) { ...do stuff.. }
but android studio says : "Common part can be extracted from 'if'"
What does that means ?
is it a problem ?
if yes, how to fix it ?
Solution
This must be a warning you are receiving from Android Studio that informs you about a change you can make to optimize your code. This specific warning usually indicates that there's an unecessary piece of code which can be removed without affecting the existing functionality, thus achieving better readability.
In general, Android Studio will provide you with a lot of warnings that help you optimize your code and it's good practice to try and resolve them.
When you get a warning on a piece of code it is highlighted in yellow and if you hover with your mouse cursor over it, a solution will be suggested to you. Alternatively, use shortcut "Alt+Enter" if you use Windows OS.
Answered By - Thanasis M
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.