Java代码命名规范.doc
文本预览下载声明
Java命名
如果不是必要,代Package 的命名Package 的名字org.项目名称.,比如myboss的包写org.myboss.*;
Class 的命名Class 的名字必Class Main(){}
Class 变量的命名变量的名字必须用一个小写字母开头。后面的单词可以用大写字母开头。 例如Main main = new Mail();Static Final 变量的命名Static Final 变量的名字应该都大写,并且以_开头,并且指出完整含义,例如?? public static final int _STOPPED = 0;
参数的命名参数的名字必数数byte[] buffer;
而不是:byte buffer[];
方法的参数使用有意
setCounter(int size){?this.size = size;}
Java 文件所有的 Java(*.java) 文件都必
版权信息版 java 文件的
/**?* Redistribution and use of this software and associated documentation?* (Software), with or without modification, are permitted provided?* that the following conditions are met:?*?* 1. Redistributions of source code must retain copyright?*??? statements and notices.? Redistributions must also contain a?*??? copy of this document.?*?* 2?. Due credit should be given to the Jetwebs.org?*??? ?*?* THIS SOFTWARE IS PROVIDED BY Jetwebs.org AND CONTRIBUTORS?* ``AS IS AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT?* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND?* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.? IN NO EVENT SHALL?* JETWEBS.ORG OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,?* Copyright 2009 (C)? Jetwebs.org. All Rights Reserved.?*?* $Id: Main.java,v 1.0 2009/11/24 08:40:32 jeff Exp $?*?* Date???????? Author? ?Changes?* 11/20/2008?? jeff??created?* 11/26/2008?? jeff??Formated?*/其他不需要出 javadoc 的信息也可以包含在其中在末尾部分是本文件信息,包括 $Id,Package/Importspackage 行要在 import 行之前,空一行,import 中 import 行中包含了同一个包中的不同子目 * 来
package org.myboss;
import java.io.*;import java.net.URL;import javax.management.MBeanException;
接下来的是Class的注释,一般是用来解释类的。
接下来是 extends 和 implements public class CounterSet??extends Observable??implements Cloneable
Class Fields接下来是/**?* Packet counters?*/protected int[] packets;
public 的成JavaDoc)。proceted、private和 package 定变量如果名字含存取方法接下来是写在一行上。
/**?* Get the counters?* @return an array containing the statistical data.? This array has been?* freshly allocated and can be m
显示全部