I expect your code to conform to the following stylistic guidelines.
There are several "acceptable" forms of indentation in the Java world. In general, as long as you are consistent, things should be okay. In general, if you simply allow Eclipse to indent your code, you should be fine. You might recall that you can force Eclipse to re-indent a block of code by selecting it and using the "Source:Correct Indentation" menu command. (There is a keyboard short cut, but it differs by platform.)
Class and interface names should start with a capital letter. All other characters should be lowercase except for those starting another "word". Examples: MattsFirstClass, FuzzyHeadedSkink, etc.
Constant identifiers should consist of all capital letters, with underbars "_" used as word delimiters. Example:
static final int MATTS_WEIGHT = 304;
All other identifiers (variables, parameters, method names, etc.) start with a lowercase letter. All other characters should be lowercase except for those starting another "word". Examples: mattsFirstMethod, makeASkink, etc.
All identifiers should be mneumonic. So, don't use overly terse identifiers like "i", unless their meaning is very clear. For example, "x" is a very short variable name, but if it is representing part of a Cartesian coordinate, then all is well.
Every method should have a header comment. Recall that Eclipse can generate these for you automatically: put the cursor in the name of the method in its declaration, then use the "Source:Generate Element Comment" menu command. The block comment should contain a brief description of what the method does, as well as a Javadoc @param statement for each parameter and a @return statement if the method is not void. Here's an example:
/** * Given a move specification, returns a String equivalent. * * @param nextMove Sequence of positions (1-32) on the board * @return The move sequence as a string */ public static String moveToString(int[] nextMove) { String result = ""; for (int i = 0; i < nextMove.length; i++) { result += nextMove[i] + " "; } return result; }
Every class should have a header comment. You can generate those via Eclipse in the same as as method header comments. Here is an example:
/** * Demonstrates how text files can by Java programs. * @author matt * */ public class TextFileInputDemo { public static void main(String[] args) { try { BufferedReader inputStream = new BufferedReader(new FileReader("morestuff2.txt")); .... }
If you want a full description of what the outside world recommends as the coding style for Java you can take a look here. And here is a slightly different style, directly from Sun (the makers of Java).