Use ternary operators: =========================== if(a == 2){ some code gets executed...; } else { some other code gets executed...; } can be abbreviated to this: (a == 2 ? some code : some other code); Shorter, huh?