Which way will be more efficient ? (Java Android Programming) -
in app need change value of integer variable . way have changed ,
int variable; if (condition) { variable= 1; } else if (condition) { variable= 2 ; } .......... .......... else { variable=3; }
or shpould declare array , change value of variable
int variable; if (condition) { variable= array[0]; } else if (condition) { variable= array[1]; } .......... .......... else { variable=0; }
which more performance optimized way ? or both same ?
you can use switch statement instead more clarity , fast access if there else if ladder
Comments
Post a Comment