文章詳情頁(yè)
Java程序的編碼規(guī)范(2)
瀏覽:220日期: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)該用 * 來(lái)處理。 package hotlava.net.stats;import java.io.*;import java.util.Observable;import hotlava.util.Application; 這里 java.io.* 使用來(lái)代替InputStream and OutputStream 的。 ● Class 接下來(lái)的是類(lèi)的注釋?zhuān)话闶怯脕?lái)解釋類(lèi)的。 /** * 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 */ 接下來(lái)是類(lèi)定義,包含了在不同的行的 extends 和 implements : public class CounterSet extends Observable implements Cloneable ● Class Fields 接下來(lái)是類(lèi)的成員變量: /** * Packet counters */protected int[] packets; public 的成員變量必須生成文檔(JavaDoc)。proceted、private和 package 定義的成員變量如果名字含義明確的話(huà),可以沒(méi)有注釋。 ● 存取方法 接下來(lái)是類(lèi)變量的存取的方法。它只是簡(jiǎn)單的用來(lái)將類(lèi)的變量賦值獲取值的話(huà),可以簡(jiǎn)單的寫(xiě)在一行上。 /** * 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; } 其它的方法不要寫(xiě)在一行上。 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. Docker安裝、創(chuàng)建鏡像、加載并運(yùn)行NodeJS程序的詳細(xì)過(guò)程2. 使用java實(shí)現(xiàn)云端資源共享小程序的代碼3. asp程序執(zhí)行數(shù)據(jù)庫(kù)的效率提升建議4. pip已經(jīng)安裝好第三方庫(kù)但pycharm中import時(shí)還是標(biāo)紅的解決方案5. 使用Canal實(shí)現(xiàn)PHP應(yīng)用程序與MySQL數(shù)據(jù)庫(kù)的實(shí)時(shí)數(shù)據(jù)同步6. 程序猿說(shuō)love的100種語(yǔ)言7. Python 如何調(diào)試程序崩潰錯(cuò)誤8. 微信小程序授權(quán)登錄的最新實(shí)現(xiàn)方案詳解(2023年)9. python import 上級(jí)目錄的導(dǎo)入10. .NET一行代碼實(shí)現(xiàn)GC調(diào)優(yōu),讓程序不再占用內(nèi)存
排行榜

網(wǎng)公網(wǎng)安備