【问题标题】:How should the parameter of the main method be documented [closed]应该如何记录主要方法的参数[关闭]
【发布时间】:2015-02-26 02:12:32
【问题描述】:

我应该如何记录下面方法的参数?

public static void main (String[] args) throws IOException

我应该使用@param吗?

【问题讨论】:

    标签: java javadoc main args


    【解决方案1】:

    使用 JavaDoc...

    /**
     * Our main method. Some kind of handy description goes here.
     * @param args The command line arguments.
     * @throws java.io.IOException when we can't read a file or something like that.
     **/
    public static void main(String[] args) throws IOException {
      ...
    }
    

    Here is a document 了解 JavaDoc cmets 的工作原理。

    【讨论】:

    • 支持理解问题并基于此提供答案......(这比我阅读问题后得到的要多)
    【解决方案2】:

    使用javadoc,但对于数组(包括可变参数),我更喜欢描述每个元素的含义,例如

    /**
     * Copies a file
     * @param args[0] The source file path
     * @param args[1] The target file path
     * @throws IOException if an error occurs
     **/
    public static void main(String[] args) throws IOException {
      //
    }
    

    虽然这不是“官方认可的”(AFAIK),但要清楚得多。

    如果这是一个“主要”方法,那么记录异常有点毫无意义,因为没有任何东西可以捕捉到它。

    【讨论】:

      猜你喜欢
      • 2013-01-25
      • 2012-09-09
      • 2013-07-25
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      • 2016-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多