Eclipse Magic - Formatting your code!
Ok, here's something that I learned from my supposedly team lead. Unfortunately, it seems that she won't be staying long here in our company. Anyway, here it goes.
I'm assuming you already have Eclipse and a class file setup. Now type in this code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public class CleanUpTest { int field1; String field2; public int getField1() { return field1; } public void setField1(int field1) { this.field1 = field1; } public String getField2() { return field2; } public void setField2(String field2) { this.field2 = field2; }
} |
That, or something similar. Just don't mess with the curly braces first or you'll defeat the purpose of this tutorial.
You should a setting similar to mine... It doesn't matter how many packages you have, just have at least 1 class file with code written in it.

Now click on window, and then preferences

The preferences window should appear. Collapse the Java menu, code style and then clik on formatter.

Click on new button. A small window similar to the screen below should appear. Type-in MyFormatter for the name and just choose Eclipse[build-in] on the drop-down menu. Click ok.

You should be brought to the Edit Profile window. Here, you can define how you want to format your code. Try to play with it. For the sake of this example, just click on Braces tab and change all "Next "line". Click ok until you're back into your main workspace.

Right click anywhere in your code. Click on source, format and....

tadaaaaaaaaa!

Now I arranged my code according to my preference! Pretty neat eh? This is also available in other IDE's. I just wanted to share this because for about 11 months of using eclipse, I didn't know this until now!