public class Square extends Shape implements Runnable{ ... }
public static final int MAX = 50;
private double area; private Coordinate[] vertices; private double timeOfDay; public static final int WEDNESDAY = 3;
// dimensions of a box in inches private int width; private int height; private int depth;
/** THIS IS AN EXAMPLE OF A javadoc STYLE COMMENT * * Tests if this Day object is a week day (not a Saturday or Sunday). * @param msg: a message that will be printed if the day object is a week day * @return true if this Day object is a week day, otherwise return false. */ public boolean isAWeekDay(String msg) { ... } // // Convert a String representation of a day of the week // to its numerical encoding // param day: the day String to encode // returns: an numerical representation of the day String (S=0, M=1, ...) // throws: NotAValidDayException if 'day' is not a valid day // of the week // private int dayStringToInt(String day) throws NotAValidDayException { ... }
If you have a line of code or comment that is too long, then split it into two lines with good indentation. For example, the following single println method call should be broken up into two calls to the print method or into a single call with two or more strings concatenated together:
previous_stmt; System.out.println("This is an example of a very long string that caus es line wrapping and should be fixed"); next_stmt;should be replaced with:
previous_stmt; System.out.println("This is an example of a very long string that" + "caused line wrapping and now is fixed"); next_stmt;For Java statments that may be longer than 80 columns, break the statement up into logical pieces each on its own line and each indented in the same way. For example:
for(int index = foo.GetInitialValue(); index <= foo.GetStopValue(); index + = foo.GetStepAmount()) { // for loop body }should be re-written with a carriage return between parts of the for-loop statment and each part indented so that it is clear that it is part of the for statement:
for(int index = foo.GetInitialValue(); index <= foo.GetStopValue(); index += foo.GetStepAmount()) { // for loop body }
The easiest way to ensure that you do not wrap lines is to resize your editor window so that it is 80 columns wide.