我在为 main 方法的 @param 编写 Javadoc 注释时遇到问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18744451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 10:39:25  来源:igfitidea点击:

I'm having issues writing Javadoc comments for main method's @param

javacommentsjavadocparam

提问by user2769212

I'm very new to Java and taking an online course with little feedback.

我对 Java 非常陌生,正在参加几乎没有反馈的在线课程。

I think I have the program completed okay, but my prof requires comments to be done and I've had no guidance on them. My biggest area seems to be the @param comments. I've tried putting different things in there but nothing is correct. Can anyone tell me what I'm doing wrong? Give me a link for easy to read info on @param comments.

我想我的程序已经完成了,但我的教授要求完成评论,我没有任何指导。我最大的领域似乎是@param 评论。我试过在里面放不同的东西,但没有什么是正确的。谁能告诉我我做错了什么?给我一个链接,以便于阅读有关@param 评论的信息。

Here's my code:

这是我的代码:

/**
 * 
 */
package edu.westga.cs6311.rectangles;

import java.awt.Rectangle;

/**
 * The RectangleIntersection class creates two rectangles that overlap (making a third rectangle) with a fourth rectangle not overlapping.
 * @author Tanya Fairbanks
 * @version 9/8/2013
 */
public class RectangleIntersection {

    /**
     * The main method is where the rectangles are created.
     * @param   rectangle1  the original rectangle
     * @param   rectangle2  the overlapping rectangle
     * @param   rectangle3  the rectangle made from intersecting rectangle1 & rectangle2
     * @param   rectangle4  the rectangle made that does not intersect with rectangle3
     */
    public static void main(String[] args) {
        // make 2 overlapping rectangles 

        Rectangle rectangle1 = new Rectangle(3, 12, 5, 3);
        Rectangle rectangle2 = new Rectangle(5, 11, 6, 4);

        System.out.println(rectangle1);
        System.out.println(rectangle2);

        //intersection of rectangles 1 & 2 is rectangle3
        Rectangle rectangle3 = rectangle1.intersection(rectangle2);
        System.out.println(rectangle3);


        //figure the area of rectangle3
        double width = rectangle3.getWidth();
        double height = rectangle3.getHeight();
        double area = width * height;
        System.out.println("Expected area: 9.0 ");
        System.out.println("Calculated area: " + area);

        //create 4th rectangle that doesn't overlap 3rd

        Rectangle rectangle4 = new Rectangle(1, 15, 13, 12);
        System.out.println(rectangle4);

        //find intersection of 3rd and 4th rectangles
        Rectangle theIntersection = rectangle3.intersection(rectangle4);
        System.out.println(theIntersection);

        //print expected area and calculated area of theIntersection

        double width2 = theIntersection.getWidth();
        double height2 = theIntersection.getHeight();
        double area2 = width2 * height2;
        System.out.println("Expected area: 0.0");
        System.out.println("Calculated area: " + area2);



    }

}

回答by Nikos Paraskevopoulos

@parammust match an argument of the method being documented, e.g:

@param必须匹配所记录方法的参数,例如:

/**
 * A method that adds x and y.
 * @param x The first operand
 * @param y The second operand
 */
public int add(int x, int y) {
    return x+y;
}

In your case, you want to document program command-line arguments. Use plain javadocs to do that.

在您的情况下,您想要记录程序命令行参数。使用普通的 javadoc 来做到这一点。