就算不是在寫公用API
也可以寫給自己用
可以自動產生網頁版的API文件
這裡示範一個簡單的用法:
1. 使用 /** --*/ 為程式碼下注解
示範用類別:
package learning.test; import java.util.ArrayList; public class InventorySystem { /** 道具欄的總格數 */ int totalGrid; /** 物品儲存List */ ArrayList<Object> al; /** 建構函式 */ public InventorySystem(int totalGrid) { super(); this.totalGrid = totalGrid; al = new ArrayList<Object>(totalGrid); } /** 將物品放入道具欄 */ public static boolean putItem(Object item) { return true; } /** 藉由物品id取得物品 */ public static Object getItemObjectById(int id) { return new Object(); } /** 藉由物品id取得物品數量 */ public static int getItemNumberById(int id) { return 520; } }
2.Eclipse 上選Project -> Generate Javadoc