មេរៀនទី៣២: ការបង្កើត API

យើងអាចបង្កើត api ក្នុង java ដោយជួយក្នុង javadoc tool។ ក្នុង java file, យើងត្រូវប្រើ documentation comment /**… */ ដើម្បី post ព័ត៌មានសម្រាប់ class, method, constructor, fields ។ល។
class ដែលផ្ទុក documentation comment
package com.abc;
/** This class is a user-defined class that contains one methods cube.*/
public class M{
/** The cube method prints cube of the given number */
public static void  cube(int n){System.out.println(n*n*n);}
}
ដើម្បីបង្កើត document API, លោកអ្នកត្រូវប្រើ javadoc tool ដែលអនុញ្ញាតដោយឈ្មោះ java file name។  ដោយមិនត្រូវការ compile javafile។
លើ command prompt, លោកអ្នកត្រូវការសរសេរ:
javadoc M.java