30 likes | 147 Views
Java Style. Variables: Variable names start with lower case character and separate words by raising the first letter of successive words, e.g. line, audioSystem. Names for constants use all capital letters and underscore “_” to separate words, e.g., MAX_ITERATIONS.
E N D
Java Style • Variables: • Variable names start with lower case character and separate words by raising the first letter of successive words, e.g. line, audioSystem. • Names for constants use all capital letters and underscore “_” to separate words, e.g., MAX_ITERATIONS. • Variables with larger scope use longer names and otherwise use shorter names. • Boolean variables has the format isX, e.g., isVisible, isSet. • Abbreviations of words should be avoided. • Avoid using magic numbers; define constants instead. • Variables should be declared where they are used and localized in a small scope.
Java Style • Layouts: • Use indentation to increase clarity. • Put white spaces around operators and colons; put one white space after key words and commas; • Insert blank rows between logic statement blocks. • While statements use the following two styles: while (condition) { statements; } while (condition) { statements; } or if (condition) { statements; } else if (condition) { statements; } else { statements; } 6. If statements 5. Do-while Statements do { statements; } while (condition);
Java Style 7. Do-while Statements for (initialization; condition; update) { statements; }