Aqua Phoenix
     >>  Lectures >>  Java 1  
 

Navigator
   
 
       
   

1.16 Syntax and Style

Blocks of code, whether classes, methods, or loops, are enclosed in curly brackets: { } Every line of code that does not end with a curly bracket is completed with a semi-colon: ; Comments can be added by using the following notations:
  • // (two slashes) place a comment until the end of the line
  • /* ... */ (slash asterisk ... asterisk slash) places a multi-line comment

The style in which code is written depends very much on the individual developer. Here are a few guidelines that are well-adopted for Java programming:

  • Vriable names should start with a lowercase letter, and every word afterwards should be capitalized, e.g. x , xPrime , xDoublePrime
  • Classnames should have capitalized words, e.g. MyClass , TableCellEventHandler , OrangeMochaFrappachino
  • Instantiated Objects should follow a similar notation to variables, e.g. myClass , tableCellEventHandler , orangeMochaFrappachino
  • Do not use excessively detailed wording, e.g. TheObjectThatPackedItsBagsAndLeftMyJavaCode . Glancing over the existing Java objects should give a good idea of what's too lengthy.