// Local.java: common programming mistakes /* Localize scope of variables; use declarations in for loops. Declare and initialize variables at the same time. Use "final" for single-assigment variables. Don't test, return, set, etc boolean constants. Use horizontal and vertical space wisely. */ class Local { public static void main (String args[]) { /*** The long way to do it. ***/ boolean b1; int temp1; // a temporary variable int i1; // a for-loop index int j1, k1; j1=5; k1=6; if (j1==k1) { b1 = true; } else { b1 = false; } for (i1=0; i1<78; i1++) { if (b1==true) { temp1 = j1; j1 = k1; k1 = temp1; } } /*** A better way to do it. ***/ int j2=5, k2=6; final boolean b2 = (j2==k2); for (int i2=0; i2<78; i2++) { if (b2) { final int temp2=j2; j2=k2; k2=temp2; } } } }