文章詳情頁(yè)
Java程序的編碼規(guī)范(2)
瀏覽:92日期:2024-07-03 10:54:15
內(nèi)容: Java程序的編碼規(guī)范(2)作者:李小敏 本文選自:IBM DW中國(guó) 2002年08月21日 其他不需要出現(xiàn)在 javadoc 的信息也可以包含在這里。 ● Package/Imports package 行要在 import 行之前,import 中標(biāo)準(zhǔn)的包名要在本地的包名之前,而且按照字母順序排列。如果 import 行中包含了同一個(gè)包中的不同子目錄,則應(yīng)該用 * 來處理。 package hotlava.net.stats;import java.io.*;import java.util.Observable;import hotlava.util.Application; 這里 java.io.* 使用來代替InputStream and OutputStream 的。 ● Class 接下來的是類的注釋,一般是用來解釋類的。 /** * A class representing a set of packet and byte counters * It is observable to allow it to be watched, but only * reports changes when the current set is complete */ 接下來是類定義,包含了在不同的行的 extends 和 implements : public class CounterSet extends Observable implements Cloneable ● Class Fields 接下來是類的成員變量: /** * Packet counters */protected int[] packets; public 的成員變量必須生成文檔(JavaDoc)。proceted、private和 package 定義的成員變量如果名字含義明確的話,可以沒有注釋。 ● 存取方法 接下來是類變量的存取的方法。它只是簡(jiǎn)單的用來將類的變量賦值獲取值的話,可以簡(jiǎn)單的寫在一行上。 /** * Get the counters * @return an array containing the statistical data. This array has been * freshly allocated and can be modified by the caller. */public int[] getPackets() { return copyArray(packets, offset); }public int[] getBytes() { return copyArray(bytes, offset); }public int[] getPackets() { return packets; }public void setPackets(int[] packets) { this.packets = packets; } 其它的方法不要寫在一行上。 Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd
標(biāo)簽:
Java
相關(guān)文章:
1. 《javascript設(shè)計(jì)模式》學(xué)習(xí)筆記七:Javascript面向?qū)ο蟪绦蛟O(shè)計(jì)組合模式詳解2. 淺談Spring中@Import注解的作用和使用3. uni-app結(jié)合.NET 7實(shí)現(xiàn)微信小程序訂閱消息推送4. 微信小程序?qū)崿F(xiàn)商品分類頁(yè)過程結(jié)束5. Python 程序員必須掌握的日志記錄6. 導(dǎo)致python中import錯(cuò)誤的原因是什么7. Spring Shell應(yīng)用程序開發(fā)流程解析8. 以文本方式上傳二進(jìn)制文件的PHP程序9. 如何將asp.net core程序部署到Linux服務(wù)器10. php面向?qū)ο蟪绦蛟O(shè)計(jì)介紹
排行榜
