• 2018/01/01Java基础学习——如何通过dos系统的javadoc命令生成API文档


    通常在Java原程序中插入类似这样的注释,/** ... ... */这样的格式可以通过Javados命令生成doc帮助文档。代码案例如下:

     1 import java.util.Arrays;
     2  
     3 /**
     4  * Description
     5  * <br> this's a test class
     6  * Created by test on 2017/2/7.
     7  * @author MisJersion
     8  * @version 1.8
     9  */
    10 public class HelloWorld{
    11        public static void fill(int[][] array) {
    12             /**
    13              * 执行赋值操作
    14              */
    15             for (int i = 0; i < array.length; i++) {
    16                 for (int j = 0; j < array[i].length; j++) {
    17                     array[i][j] = (int) (Math.random()*100);
    18                 }
    19             }
    20         }
    21         public static void sort(int[][] array) {
    22             /**
    23              * 先把二维数组使用System.arraycopy进行数组复制到一个一维数组
    24              * 然后使用sort进行排序
    25              * 最后再复制回到二维数组。
    26              */
    27             int[] a = new int[array.length * array[0].length];
    28             int b = 0;
    29             int c = 0;
    30             for (int i = 0; i < array.length; i++) {
    31                 System.arraycopy(array[i],0,a,b,array[i].length);
    32                 b += array[i].length;
    33             }
    34             Arrays.sort(a);
    35             System.out.println(Arrays.toString(a));
    36             for (int i = 0; i < array.length; i++) {
    37                 System.arraycopy(a,c,array[i],0,array[i].length);
    38                 c += array[i].length;
    39                 System.out.println(Arrays.toString(array[i]));
    40             }
    41         }
    42         public static void main(String[] args) {
    43             int[][] a = new int[5][8];
    44             fill(a);
    45             sort(a);
    46         }
    47 }

    下面讲解如何生成doc帮助文档

    方法一:

    1. 打开dos界面:win + R, 然后输入cmd
    2. 拿我自己的.java路径来举例,输入:E:+enter
    3. 输入:cd E:projectj2sesrc,然后enter
    4. javadoc 类名.java,然后enter
    5. 打开根目录E:projectj2sesrc,找到index.html索引网页,双击打开,就可以查看了
    6. 点击其中的类,可以看到相应类的信息,如你设置的版本、作者,还可以看到继承的类等信息,有助于快速了解源代码

      方法一的优点是快速,其实还有一种更快的方式,但是建成的.HTML文件比较乱。所以推荐了下面的方法。

    方法二:参考链接: 如何使用javadoc命令生成api文档、文档注释

    1. 第一步方法同『方法一』的前三步
    2. 创建api文件,进行文档生成:输入『javadoc -d javaapi -header 测试的API -doctitle 这是我的第一个文档注释 -version -author 类名.java
    3. 打开根目录E:projectj2sesrc:可以看到生成了一个文件夹javaapi,这样就不乱了。

       

      【note注意】上述的类名.java在这里是HelloWorld.java。

  • 相关阅读:
    02-链路层
    01-TCP/IP概述
    ARM Cortex-A9 (tiny 4412)
    STM32 f407 温湿度采集报警
    arduino mega 避障报距小车
    归纳法调试
    python 数据类型Ⅲ(字典)
    Python 数据类型Ⅱ(列表,元祖)
    Python 数据类型(str,int,bool)
    Python while循环&格式化输出&运算符
  • 原文地址:https://www.cnblogs.com/lijiehua/p/8166309.html
Copyright © 2020-2023  润新知