2007年5月11日 星期五

Java 程式碼慣例 -- 第十一章 程式碼範例

下列範例顯示了如何格式化一個包含單一 public 類別的 Java 原始碼檔案
。介面也以相似的方法格式化。更多的資訊請參閱 3.1.3 小節的 "class 和
interface 宣告" 和 5.2 小節的 "文件註解" 。

/*
* @(#)Blah.java 1.82 99/03/18
*
* Copyright (c) 1994-1999 Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
* All rights reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*/

package java.blah;

import java.blah.blahdy.BlahBlah;

/**
* 類別描述在這裡。
*
* @version 1.82 18 Mar 1999
* @author 姓名
*/
public class Blah extends SomeClass {
  /* 類別實作註解在此。 */

  /** classVar1 文件註解 */
  public static int classVar1;

  /**
   * 會超過一行長度的 classVar2
   * 文件註解
   */
  private static Object classVar2;

  /** instanceVar1 文件註解 */
  public Object instanceVar1;

  /** instanceVar2 文件註解 */
  protected int instanceVar2;

  /** instanceVar3 文件註解 */
  private Object[] instanceVar3;

  /**
   * ...Blah 建構子文件註解...
   */
  public Blah() {
    // ...實作在此...
  }

  /**
   * ...doSomething 方法文件註解...
   */
  public void doSomething() {
    // ...實作在此...
  }

  /**
   * ...doSomethingElse 方法文件註解...
   * @param someParam 描述
   */
  public void doSomethingElse(Object someParam) {
    // ...實作在此...
  }
}

沒有留言:

網誌存檔

關於我自己

Aspire freedom , Hope to do Soming make self complete ~