Consider the following piece of Java code:
public class C{public static void main(String y[]) {int x=Integer.parseInt(y[0]);int z = Integer.parseInt(y[1]); if(x<=z){for (int nnnnnnnn=x; nnnnnnnn<=z; nnnnnnnn++ ) {if (nnnnnnnn % 2 ==0) { System.out.print(nnnnnnnn+" ");}}}else{System.out.println(x+ " cannot be greater than " + z);} }}
It’s not pretty, is it? And it’s a bit hard to figure out what the program is supposed to do.
There’s a nice feature in nearly every IDE which helps you format your code nicely. First, create a new IntelliJ project and copy and paste the jumble above into a new class which you should call C to begin with. Now, go to the Code menu and select Reformat Code. This should have the effect of magically improving the indentation and spacing. And the result will be much more readable. You might need to remove some newlines and run the command again. It is worth remembering the keyboard shortcut for this feature which is indicated next to the Reformat Code entry.
However, the names of the class itself and the variables are not very informative, are they? That’s where another nice feature nearly every IDE comes in useful. Double-click on one of the occurrences of the variable name nnnnnnnn. Now go to the Refactor menu and select Rename. Type in index and hit return. Now all occurrences of the variable will be renamed. Go ahead and see if you can find more informative names for the variables x and z and y, using the same Rename feature. Finally, you can even rename the class from C to something which might give the reader a hint about what the program is meant to do.