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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -